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