@itwin/presentation-backend 4.0.0-dev.8 → 4.0.0-dev.80
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 +47 -1
- package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +5 -3
- package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
- package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
- package/lib/cjs/presentation-backend/Constants.js +40 -36
- package/lib/cjs/presentation-backend/Constants.js.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +260 -262
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +140 -140
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
- package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +148 -150
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +12 -12
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +41 -41
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +456 -445
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +309 -311
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +430 -430
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
- package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +284 -279
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
- package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
- package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +210 -213
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
- package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
- package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
- package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
- package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +107 -106
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
- package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
- package/lib/cjs/presentation-backend.d.ts +19 -19
- package/lib/cjs/presentation-backend.js +39 -35
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/package.json +18 -18
|
@@ -1,431 +1,431 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
...
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
//
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
return new ((0, NativePlatform_1.createDefaultNativePlatform)({
|
|
370
|
-
id,
|
|
371
|
-
taskAllocationsMap: { [Number.MAX_SAFE_INTEGER]: workerThreadsCount },
|
|
372
|
-
isChangeTrackingEnabled: changeTrackingEnabled,
|
|
373
|
-
cacheConfig: createCacheConfig(caching
|
|
374
|
-
contentCacheSize:
|
|
375
|
-
workerConnectionCacheSize: caching
|
|
376
|
-
defaultFormats: toNativeUnitFormatsMap(defaultFormats),
|
|
377
|
-
useMmap,
|
|
378
|
-
}))();
|
|
379
|
-
function createCacheConfig(config) {
|
|
380
|
-
switch (config
|
|
381
|
-
case PresentationManager_1.HierarchyCacheMode.Disk:
|
|
382
|
-
return { ...config, directory: normalizeDirectory(config.directory) };
|
|
383
|
-
case PresentationManager_1.HierarchyCacheMode.Hybrid:
|
|
384
|
-
return {
|
|
385
|
-
...config,
|
|
386
|
-
disk: config.disk ? { ...config.disk, directory: normalizeDirectory(config.disk.directory) } : undefined,
|
|
387
|
-
};
|
|
388
|
-
case PresentationManager_1.HierarchyCacheMode.Memory:
|
|
389
|
-
return config;
|
|
390
|
-
default:
|
|
391
|
-
return { mode: PresentationManager_1.HierarchyCacheMode.Disk, directory: "" };
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
function normalizeDirectory(directory) {
|
|
395
|
-
return directory ? path.resolve(directory) : "";
|
|
396
|
-
}
|
|
397
|
-
function toNativeUnitFormatsMap(map) {
|
|
398
|
-
if (!map) {
|
|
399
|
-
return undefined;
|
|
400
|
-
}
|
|
401
|
-
const nativeFormatsMap = {};
|
|
402
|
-
Object.keys(map).forEach((phenomenon) => {
|
|
403
|
-
const unitSystemsFormat = map[phenomenon];
|
|
404
|
-
nativeFormatsMap[phenomenon] = {
|
|
405
|
-
unitSystems: unitSystemsFormat.unitSystems.map(toNativeUnitSystem),
|
|
406
|
-
format: unitSystemsFormat.format,
|
|
407
|
-
};
|
|
408
|
-
});
|
|
409
|
-
return nativeFormatsMap;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
function toOptionalNativeUnitSystem(unitSystem) {
|
|
413
|
-
return unitSystem ? toNativeUnitSystem(unitSystem) : undefined;
|
|
414
|
-
}
|
|
415
|
-
function toNativeUnitSystem(unitSystem) {
|
|
416
|
-
switch (unitSystem) {
|
|
417
|
-
case "imperial": return NativePlatform_1.NativePresentationUnitSystem.BritishImperial;
|
|
418
|
-
case "metric": return NativePlatform_1.NativePresentationUnitSystem.Metric;
|
|
419
|
-
case "usCustomary": return NativePlatform_1.NativePresentationUnitSystem.UsCustomary;
|
|
420
|
-
case "usSurvey": return NativePlatform_1.NativePresentationUnitSystem.UsSurvey;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function collateAssetDirectories(mainDirectory, additionalDirectories) {
|
|
424
|
-
return [...new Set([mainDirectory, ...additionalDirectories])];
|
|
425
|
-
}
|
|
426
|
-
const createContentDescriptorOverrides = (descriptorOrOverrides) => {
|
|
427
|
-
if (descriptorOrOverrides instanceof presentation_common_1.Descriptor)
|
|
428
|
-
return descriptorOrOverrides.createDescriptorOverrides();
|
|
429
|
-
return descriptorOrOverrides;
|
|
430
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.bisElementInstanceKeysProcessor = exports.getKeysForContentRequest = exports.getRulesetIdObject = exports.PresentationManagerDetail = void 0;
|
|
27
|
+
/*---------------------------------------------------------------------------------------------
|
|
28
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
29
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
30
|
+
*--------------------------------------------------------------------------------------------*/
|
|
31
|
+
const hash = __importStar(require("object-hash"));
|
|
32
|
+
const path = __importStar(require("path"));
|
|
33
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
34
|
+
const presentation_common_1 = require("@itwin/presentation-common");
|
|
35
|
+
const Constants_1 = require("./Constants");
|
|
36
|
+
const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
|
|
37
|
+
const NativePlatform_1 = require("./NativePlatform");
|
|
38
|
+
const PresentationManager_1 = require("./PresentationManager");
|
|
39
|
+
const RulesetManager_1 = require("./RulesetManager");
|
|
40
|
+
const UpdatesTracker_1 = require("./UpdatesTracker");
|
|
41
|
+
const Utils_1 = require("./Utils");
|
|
42
|
+
/** @internal */
|
|
43
|
+
class PresentationManagerDetail {
|
|
44
|
+
constructor(params) {
|
|
45
|
+
this._disposed = false;
|
|
46
|
+
const backendAssetsRoot = ((typeof params.presentationAssetsRoot === "string")
|
|
47
|
+
? params.presentationAssetsRoot
|
|
48
|
+
: params.presentationAssetsRoot?.backend) ?? Constants_1.PRESENTATION_BACKEND_ASSETS_ROOT;
|
|
49
|
+
const changeTrackingEnabled = !!params.updatesPollInterval;
|
|
50
|
+
this._nativePlatform = params.addon ?? createNativePlatform(params.id ?? "", params.workerThreadsCount ?? 2, changeTrackingEnabled, params.caching, params.defaultFormats, params.useMmap);
|
|
51
|
+
const getNativePlatform = () => this.getNativePlatform();
|
|
52
|
+
if (core_backend_1.IpcHost.isValid && changeTrackingEnabled) {
|
|
53
|
+
this._updatesTracker = UpdatesTracker_1.UpdatesTracker.create({
|
|
54
|
+
nativePlatformGetter: getNativePlatform,
|
|
55
|
+
pollInterval: params.updatesPollInterval,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this._updatesTracker = undefined;
|
|
60
|
+
}
|
|
61
|
+
setupRulesetDirectories(this._nativePlatform, backendAssetsRoot, params.supplementalRulesetDirectories ?? [], params.rulesetDirectories ?? []);
|
|
62
|
+
this.activeUnitSystem = params.defaultUnitSystem;
|
|
63
|
+
this._onManagerUsed = undefined;
|
|
64
|
+
this.rulesets = new RulesetManager_1.RulesetManagerImpl(getNativePlatform);
|
|
65
|
+
this._diagnosticsOptions = params.diagnostics;
|
|
66
|
+
}
|
|
67
|
+
dispose() {
|
|
68
|
+
if (this._disposed) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.getNativePlatform().dispose();
|
|
72
|
+
this._nativePlatform = undefined;
|
|
73
|
+
this._updatesTracker?.dispose();
|
|
74
|
+
this._updatesTracker = undefined;
|
|
75
|
+
this._disposed = true;
|
|
76
|
+
}
|
|
77
|
+
getNativePlatform() {
|
|
78
|
+
if (this._disposed) {
|
|
79
|
+
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.NotInitialized, "Attempting to use Presentation manager after disposal");
|
|
80
|
+
}
|
|
81
|
+
return this._nativePlatform;
|
|
82
|
+
}
|
|
83
|
+
setOnManagerUsedHandler(handler) {
|
|
84
|
+
this._onManagerUsed = handler;
|
|
85
|
+
}
|
|
86
|
+
async getNodes(requestOptions) {
|
|
87
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
88
|
+
const params = {
|
|
89
|
+
requestId: parentKey ? NativePlatform_1.NativePlatformRequestTypes.GetChildren : NativePlatform_1.NativePlatformRequestTypes.GetRootNodes,
|
|
90
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
91
|
+
...strippedOptions,
|
|
92
|
+
nodeKey: parentKey,
|
|
93
|
+
};
|
|
94
|
+
return this.request(params);
|
|
95
|
+
}
|
|
96
|
+
async getNodesCount(requestOptions) {
|
|
97
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
98
|
+
const params = {
|
|
99
|
+
requestId: parentKey ? NativePlatform_1.NativePlatformRequestTypes.GetChildrenCount : NativePlatform_1.NativePlatformRequestTypes.GetRootNodesCount,
|
|
100
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
101
|
+
...strippedOptions,
|
|
102
|
+
nodeKey: parentKey,
|
|
103
|
+
};
|
|
104
|
+
return JSON.parse(await this.request(params));
|
|
105
|
+
}
|
|
106
|
+
async getNodesDescriptor(requestOptions) {
|
|
107
|
+
const { rulesetOrId, parentKey, ...strippedOptions } = requestOptions;
|
|
108
|
+
const params = {
|
|
109
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetNodesDescriptor,
|
|
110
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
111
|
+
...strippedOptions,
|
|
112
|
+
nodeKey: parentKey,
|
|
113
|
+
};
|
|
114
|
+
return this.request(params);
|
|
115
|
+
}
|
|
116
|
+
async getNodePaths(requestOptions) {
|
|
117
|
+
const { rulesetOrId, instancePaths, ...strippedOptions } = requestOptions;
|
|
118
|
+
const params = {
|
|
119
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetNodePaths,
|
|
120
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
121
|
+
...strippedOptions,
|
|
122
|
+
paths: instancePaths,
|
|
123
|
+
};
|
|
124
|
+
return JSON.parse(await this.request(params), presentation_common_1.NodePathElement.listReviver);
|
|
125
|
+
}
|
|
126
|
+
async getFilteredNodePaths(requestOptions) {
|
|
127
|
+
const { rulesetOrId, ...strippedOptions } = requestOptions;
|
|
128
|
+
const params = {
|
|
129
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetFilteredNodePaths,
|
|
130
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
131
|
+
...strippedOptions,
|
|
132
|
+
};
|
|
133
|
+
return JSON.parse(await this.request(params), presentation_common_1.NodePathElement.listReviver);
|
|
134
|
+
}
|
|
135
|
+
async getContentDescriptor(requestOptions) {
|
|
136
|
+
const { rulesetOrId, ...strippedOptions } = requestOptions;
|
|
137
|
+
const params = {
|
|
138
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetContentDescriptor,
|
|
139
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
140
|
+
...strippedOptions,
|
|
141
|
+
contentFlags: presentation_common_1.ContentFlags.DescriptorOnly,
|
|
142
|
+
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
143
|
+
};
|
|
144
|
+
return this.request(params);
|
|
145
|
+
}
|
|
146
|
+
async getContentSources(requestOptions) {
|
|
147
|
+
const params = {
|
|
148
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetContentSources,
|
|
149
|
+
rulesetId: "ElementProperties",
|
|
150
|
+
...requestOptions,
|
|
151
|
+
};
|
|
152
|
+
const reviver = (key, value) => {
|
|
153
|
+
return key === "" ? presentation_common_1.SelectClassInfo.listFromCompressedJSON(value.sources, value.classesMap) : value;
|
|
154
|
+
};
|
|
155
|
+
return JSON.parse(await this.request(params), reviver);
|
|
156
|
+
}
|
|
157
|
+
async getContentSetSize(requestOptions) {
|
|
158
|
+
const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;
|
|
159
|
+
const params = {
|
|
160
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetContentSetSize,
|
|
161
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
162
|
+
...strippedOptions,
|
|
163
|
+
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
164
|
+
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
165
|
+
};
|
|
166
|
+
return JSON.parse(await this.request(params));
|
|
167
|
+
}
|
|
168
|
+
async getContent(requestOptions) {
|
|
169
|
+
const { rulesetOrId, descriptor, ...strippedOptions } = requestOptions;
|
|
170
|
+
const params = {
|
|
171
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetContent,
|
|
172
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
173
|
+
...strippedOptions,
|
|
174
|
+
keys: getKeysForContentRequest(requestOptions.keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
175
|
+
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
176
|
+
};
|
|
177
|
+
return JSON.parse(await this.request(params), presentation_common_1.Content.reviver);
|
|
178
|
+
}
|
|
179
|
+
async getPagedDistinctValues(requestOptions) {
|
|
180
|
+
const { rulesetOrId, ...strippedOptions } = requestOptions;
|
|
181
|
+
const { descriptor, keys, ...strippedOptionsNoDescriptorAndKeys } = strippedOptions;
|
|
182
|
+
const params = {
|
|
183
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetPagedDistinctValues,
|
|
184
|
+
rulesetId: this.registerRuleset(rulesetOrId),
|
|
185
|
+
...strippedOptionsNoDescriptorAndKeys,
|
|
186
|
+
keys: getKeysForContentRequest(keys, (map) => bisElementInstanceKeysProcessor(requestOptions.imodel, map)),
|
|
187
|
+
descriptorOverrides: createContentDescriptorOverrides(descriptor),
|
|
188
|
+
};
|
|
189
|
+
const reviver = (key, value) => {
|
|
190
|
+
return key === "" ? {
|
|
191
|
+
total: value.total,
|
|
192
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
193
|
+
items: value.items.map(presentation_common_1.DisplayValueGroup.fromJSON),
|
|
194
|
+
} : value;
|
|
195
|
+
};
|
|
196
|
+
return JSON.parse(await this.request(params), reviver);
|
|
197
|
+
}
|
|
198
|
+
async getDisplayLabelDefinition(requestOptions) {
|
|
199
|
+
const params = {
|
|
200
|
+
requestId: NativePlatform_1.NativePlatformRequestTypes.GetDisplayLabel,
|
|
201
|
+
...requestOptions,
|
|
202
|
+
};
|
|
203
|
+
return JSON.parse(await this.request(params));
|
|
204
|
+
}
|
|
205
|
+
async getDisplayLabelDefinitions(requestOptions) {
|
|
206
|
+
const concreteKeys = requestOptions.keys.map((k) => {
|
|
207
|
+
if (k.className === "BisCore:Element")
|
|
208
|
+
return (0, Utils_1.getElementKey)(requestOptions.imodel, k.id);
|
|
209
|
+
return k;
|
|
210
|
+
}).filter((k) => !!k);
|
|
211
|
+
const contentRequestOptions = {
|
|
212
|
+
...requestOptions,
|
|
213
|
+
rulesetOrId: "RulesDrivenECPresentationManager_RulesetId_DisplayLabel",
|
|
214
|
+
descriptor: {
|
|
215
|
+
displayType: presentation_common_1.DefaultContentDisplayTypes.List,
|
|
216
|
+
contentFlags: presentation_common_1.ContentFlags.ShowLabels | presentation_common_1.ContentFlags.NoFields,
|
|
217
|
+
},
|
|
218
|
+
keys: new presentation_common_1.KeySet(concreteKeys),
|
|
219
|
+
};
|
|
220
|
+
const content = await this.getContent(contentRequestOptions);
|
|
221
|
+
return concreteKeys.map((key) => {
|
|
222
|
+
const item = content ? content.contentSet.find((it) => it.primaryKeys.length > 0 && presentation_common_1.InstanceKey.compare(it.primaryKeys[0], key) === 0) : undefined;
|
|
223
|
+
if (!item)
|
|
224
|
+
return { displayValue: "", rawValue: "", typeName: "" };
|
|
225
|
+
return item.label;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
async getElementProperties(requestOptions) {
|
|
229
|
+
const { elementId, ...optionsNoElementId } = requestOptions;
|
|
230
|
+
const content = await this.getContent({
|
|
231
|
+
...optionsNoElementId,
|
|
232
|
+
descriptor: {
|
|
233
|
+
displayType: presentation_common_1.DefaultContentDisplayTypes.PropertyPane,
|
|
234
|
+
contentFlags: presentation_common_1.ContentFlags.ShowLabels,
|
|
235
|
+
},
|
|
236
|
+
rulesetOrId: "ElementProperties",
|
|
237
|
+
keys: new presentation_common_1.KeySet([{ className: "BisCore:Element", id: elementId }]),
|
|
238
|
+
});
|
|
239
|
+
const properties = (0, ElementPropertiesHelper_1.buildElementsProperties)(content);
|
|
240
|
+
return properties[0];
|
|
241
|
+
}
|
|
242
|
+
/** Registers given ruleset and replaces the ruleset with its ID in the resulting object */
|
|
243
|
+
registerRuleset(rulesetOrId) {
|
|
244
|
+
if (typeof rulesetOrId === "object") {
|
|
245
|
+
const rulesetWithNativeId = { ...rulesetOrId, id: this.getRulesetId(rulesetOrId) };
|
|
246
|
+
return this.rulesets.add(rulesetWithNativeId).id;
|
|
247
|
+
}
|
|
248
|
+
return rulesetOrId;
|
|
249
|
+
}
|
|
250
|
+
/** @internal */
|
|
251
|
+
getRulesetId(rulesetOrId) {
|
|
252
|
+
return getRulesetIdObject(rulesetOrId).uniqueId;
|
|
253
|
+
}
|
|
254
|
+
async request(params) {
|
|
255
|
+
this._onManagerUsed?.();
|
|
256
|
+
const { requestId, imodel, unitSystem, diagnostics: requestDiagnostics, cancelEvent, ...strippedParams } = params;
|
|
257
|
+
const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);
|
|
258
|
+
const response = await withOptionalDiagnostics([this._diagnosticsOptions, requestDiagnostics], async (diagnosticsOptions) => {
|
|
259
|
+
const nativeRequestParams = {
|
|
260
|
+
requestId,
|
|
261
|
+
params: {
|
|
262
|
+
unitSystem: toOptionalNativeUnitSystem(unitSystem ?? this.activeUnitSystem),
|
|
263
|
+
...strippedParams,
|
|
264
|
+
...(diagnosticsOptions ? { diagnostics: diagnosticsOptions } : undefined),
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
return this.getNativePlatform().handleRequest(imodelAddon, JSON.stringify(nativeRequestParams), cancelEvent);
|
|
268
|
+
});
|
|
269
|
+
return response.result;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
exports.PresentationManagerDetail = PresentationManagerDetail;
|
|
273
|
+
async function withOptionalDiagnostics(diagnosticsOptions, nativePlatformRequestHandler) {
|
|
274
|
+
const contexts = diagnosticsOptions.map((d) => d?.requestContextSupplier?.());
|
|
275
|
+
const combinedOptions = (0, Utils_1.combineDiagnosticsOptions)(...diagnosticsOptions);
|
|
276
|
+
const response = await nativePlatformRequestHandler(combinedOptions);
|
|
277
|
+
if (response.diagnostics) {
|
|
278
|
+
const diagnostics = { logs: [response.diagnostics] };
|
|
279
|
+
diagnosticsOptions.forEach((options, i) => {
|
|
280
|
+
options && (0, Utils_1.reportDiagnostics)(diagnostics, options, contexts[i]);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return response;
|
|
284
|
+
}
|
|
285
|
+
function setupRulesetDirectories(nativePlatform, presentationAssetsRoot, supplementalRulesetDirectoriesOverrides, rulesetDirectories) {
|
|
286
|
+
const supplementalRulesetDirectories = collateAssetDirectories(path.join(presentationAssetsRoot, "supplemental-presentation-rules"), supplementalRulesetDirectoriesOverrides);
|
|
287
|
+
nativePlatform.setupSupplementalRulesetDirectories(supplementalRulesetDirectories);
|
|
288
|
+
const primaryRulesetDirectories = collateAssetDirectories(path.join(presentationAssetsRoot, "primary-presentation-rules"), rulesetDirectories);
|
|
289
|
+
nativePlatform.setupRulesetDirectories(primaryRulesetDirectories);
|
|
290
|
+
}
|
|
291
|
+
/** @internal */
|
|
292
|
+
function getRulesetIdObject(rulesetOrId) {
|
|
293
|
+
if (typeof rulesetOrId === "object") {
|
|
294
|
+
if (core_backend_1.IpcHost.isValid) {
|
|
295
|
+
// in case of native apps we don't want to enforce ruleset id uniqueness as ruleset variables
|
|
296
|
+
// are stored on a backend and creating new id will lose those variables
|
|
297
|
+
return {
|
|
298
|
+
uniqueId: rulesetOrId.id,
|
|
299
|
+
parts: { id: rulesetOrId.id },
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
const hashedId = hash.MD5(rulesetOrId);
|
|
303
|
+
return {
|
|
304
|
+
uniqueId: `${rulesetOrId.id}-${hashedId}`,
|
|
305
|
+
parts: {
|
|
306
|
+
id: rulesetOrId.id,
|
|
307
|
+
hash: hashedId,
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return { uniqueId: rulesetOrId, parts: { id: rulesetOrId } };
|
|
312
|
+
}
|
|
313
|
+
exports.getRulesetIdObject = getRulesetIdObject;
|
|
314
|
+
/** @internal */
|
|
315
|
+
function getKeysForContentRequest(keys, classInstanceKeysProcessor) {
|
|
316
|
+
const result = {
|
|
317
|
+
instanceKeys: [],
|
|
318
|
+
nodeKeys: [],
|
|
319
|
+
};
|
|
320
|
+
const classInstancesMap = new Map();
|
|
321
|
+
keys.forEach((key) => {
|
|
322
|
+
if (presentation_common_1.Key.isNodeKey(key)) {
|
|
323
|
+
result.nodeKeys.push(key);
|
|
324
|
+
}
|
|
325
|
+
if (presentation_common_1.Key.isInstanceKey(key)) {
|
|
326
|
+
addInstanceKey(classInstancesMap, key);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
if (classInstanceKeysProcessor) {
|
|
330
|
+
classInstanceKeysProcessor(classInstancesMap);
|
|
331
|
+
}
|
|
332
|
+
for (const entry of classInstancesMap) {
|
|
333
|
+
if (entry[1].size > 0) {
|
|
334
|
+
result.instanceKeys.push([entry["0"], [...entry[1]]]);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
exports.getKeysForContentRequest = getKeysForContentRequest;
|
|
340
|
+
/** @internal */
|
|
341
|
+
function bisElementInstanceKeysProcessor(imodel, classInstancesMap) {
|
|
342
|
+
const elementClassName = "BisCore:Element";
|
|
343
|
+
const elementIds = classInstancesMap.get(elementClassName);
|
|
344
|
+
if (elementIds) {
|
|
345
|
+
const deleteElementIds = new Array();
|
|
346
|
+
elementIds.forEach((elementId) => {
|
|
347
|
+
const concreteKey = (0, Utils_1.getElementKey)(imodel, elementId);
|
|
348
|
+
if (concreteKey && concreteKey.className !== elementClassName) {
|
|
349
|
+
deleteElementIds.push(elementId);
|
|
350
|
+
addInstanceKey(classInstancesMap, { className: concreteKey.className, id: elementId });
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
for (const id of deleteElementIds) {
|
|
354
|
+
elementIds.delete(id);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
exports.bisElementInstanceKeysProcessor = bisElementInstanceKeysProcessor;
|
|
359
|
+
function addInstanceKey(classInstancesMap, key) {
|
|
360
|
+
let set = classInstancesMap.get(key.className);
|
|
361
|
+
// istanbul ignore else
|
|
362
|
+
if (!set) {
|
|
363
|
+
set = new Set();
|
|
364
|
+
classInstancesMap.set(key.className, set);
|
|
365
|
+
}
|
|
366
|
+
set.add(key.id);
|
|
367
|
+
}
|
|
368
|
+
function createNativePlatform(id, workerThreadsCount, changeTrackingEnabled, caching, defaultFormats, useMmap) {
|
|
369
|
+
return new ((0, NativePlatform_1.createDefaultNativePlatform)({
|
|
370
|
+
id,
|
|
371
|
+
taskAllocationsMap: { [Number.MAX_SAFE_INTEGER]: workerThreadsCount },
|
|
372
|
+
isChangeTrackingEnabled: changeTrackingEnabled,
|
|
373
|
+
cacheConfig: createCacheConfig(caching?.hierarchies),
|
|
374
|
+
contentCacheSize: caching?.content?.size,
|
|
375
|
+
workerConnectionCacheSize: caching?.workerConnectionCacheSize,
|
|
376
|
+
defaultFormats: toNativeUnitFormatsMap(defaultFormats),
|
|
377
|
+
useMmap,
|
|
378
|
+
}))();
|
|
379
|
+
function createCacheConfig(config) {
|
|
380
|
+
switch (config?.mode) {
|
|
381
|
+
case PresentationManager_1.HierarchyCacheMode.Disk:
|
|
382
|
+
return { ...config, directory: normalizeDirectory(config.directory) };
|
|
383
|
+
case PresentationManager_1.HierarchyCacheMode.Hybrid:
|
|
384
|
+
return {
|
|
385
|
+
...config,
|
|
386
|
+
disk: config.disk ? { ...config.disk, directory: normalizeDirectory(config.disk.directory) } : undefined,
|
|
387
|
+
};
|
|
388
|
+
case PresentationManager_1.HierarchyCacheMode.Memory:
|
|
389
|
+
return config;
|
|
390
|
+
default:
|
|
391
|
+
return { mode: PresentationManager_1.HierarchyCacheMode.Disk, directory: "" };
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
function normalizeDirectory(directory) {
|
|
395
|
+
return directory ? path.resolve(directory) : "";
|
|
396
|
+
}
|
|
397
|
+
function toNativeUnitFormatsMap(map) {
|
|
398
|
+
if (!map) {
|
|
399
|
+
return undefined;
|
|
400
|
+
}
|
|
401
|
+
const nativeFormatsMap = {};
|
|
402
|
+
Object.keys(map).forEach((phenomenon) => {
|
|
403
|
+
const unitSystemsFormat = map[phenomenon];
|
|
404
|
+
nativeFormatsMap[phenomenon] = {
|
|
405
|
+
unitSystems: unitSystemsFormat.unitSystems.map(toNativeUnitSystem),
|
|
406
|
+
format: unitSystemsFormat.format,
|
|
407
|
+
};
|
|
408
|
+
});
|
|
409
|
+
return nativeFormatsMap;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function toOptionalNativeUnitSystem(unitSystem) {
|
|
413
|
+
return unitSystem ? toNativeUnitSystem(unitSystem) : undefined;
|
|
414
|
+
}
|
|
415
|
+
function toNativeUnitSystem(unitSystem) {
|
|
416
|
+
switch (unitSystem) {
|
|
417
|
+
case "imperial": return NativePlatform_1.NativePresentationUnitSystem.BritishImperial;
|
|
418
|
+
case "metric": return NativePlatform_1.NativePresentationUnitSystem.Metric;
|
|
419
|
+
case "usCustomary": return NativePlatform_1.NativePresentationUnitSystem.UsCustomary;
|
|
420
|
+
case "usSurvey": return NativePlatform_1.NativePresentationUnitSystem.UsSurvey;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function collateAssetDirectories(mainDirectory, additionalDirectories) {
|
|
424
|
+
return [...new Set([mainDirectory, ...additionalDirectories])];
|
|
425
|
+
}
|
|
426
|
+
const createContentDescriptorOverrides = (descriptorOrOverrides) => {
|
|
427
|
+
if (descriptorOrOverrides instanceof presentation_common_1.Descriptor)
|
|
428
|
+
return descriptorOrOverrides.createDescriptorOverrides();
|
|
429
|
+
return descriptorOrOverrides;
|
|
430
|
+
};
|
|
431
431
|
//# sourceMappingURL=PresentationManagerDetail.js.map
|