@itwin/presentation-frontend 5.0.0-dev.5 → 5.0.0-dev.50

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 (80) hide show
  1. package/CHANGELOG.md +38 -1
  2. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
  3. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
  4. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +1 -1
  5. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  6. package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
  7. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  8. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  9. package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
  10. package/lib/cjs/presentation-frontend/Presentation.js +5 -5
  11. package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
  12. package/lib/cjs/presentation-frontend/PresentationManager.d.ts +4 -2
  13. package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
  14. package/lib/cjs/presentation-frontend/PresentationManager.js +6 -1
  15. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  16. package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
  17. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  18. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
  19. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +4 -2
  20. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  21. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +22 -14
  22. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  23. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
  24. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
  25. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +2 -4
  26. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  27. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  28. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  29. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  30. package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +3 -2
  31. package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
  32. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +6 -1
  33. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  34. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  35. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +25 -7
  36. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
  37. package/lib/cjs/presentation-frontend/selection/SelectionManager.js +168 -81
  38. package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
  39. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  40. package/lib/cjs/presentation-frontend.js.map +1 -1
  41. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +3 -3
  42. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
  43. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +1 -1
  44. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  45. package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
  46. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  47. package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  48. package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
  49. package/lib/esm/presentation-frontend/Presentation.js +5 -5
  50. package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
  51. package/lib/esm/presentation-frontend/PresentationManager.d.ts +4 -2
  52. package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
  53. package/lib/esm/presentation-frontend/PresentationManager.js +6 -1
  54. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  55. package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
  56. package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  57. package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
  58. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +4 -2
  59. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  60. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +23 -15
  61. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  62. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +2 -3
  63. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
  64. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +3 -5
  65. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  66. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  67. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  68. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  69. package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +3 -2
  70. package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
  71. package/lib/esm/presentation-frontend/selection/SelectionHandler.js +6 -1
  72. package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  73. package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  74. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +25 -7
  75. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
  76. package/lib/esm/presentation-frontend/selection/SelectionManager.js +169 -82
  77. package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
  78. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  79. package/lib/esm/presentation-frontend.js.map +1 -1
  80. package/package.json +18 -18
@@ -6,6 +6,58 @@
6
6
  /** @packageDocumentation
7
7
  * @module UnifiedSelection
8
8
  */
9
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
10
+ if (value !== null && value !== void 0) {
11
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
12
+ var dispose, inner;
13
+ if (async) {
14
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
15
+ dispose = value[Symbol.asyncDispose];
16
+ }
17
+ if (dispose === void 0) {
18
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
19
+ dispose = value[Symbol.dispose];
20
+ if (async) inner = dispose;
21
+ }
22
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
23
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
24
+ env.stack.push({ value: value, dispose: dispose, async: async });
25
+ }
26
+ else if (async) {
27
+ env.stack.push({ async: true });
28
+ }
29
+ return value;
30
+ };
31
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
32
+ return function (env) {
33
+ function fail(e) {
34
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
35
+ env.hasError = true;
36
+ }
37
+ var r, s = 0;
38
+ function next() {
39
+ while (r = env.stack.pop()) {
40
+ try {
41
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
42
+ if (r.dispose) {
43
+ var result = r.dispose.call(r.value);
44
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
45
+ }
46
+ else s |= 1;
47
+ }
48
+ catch (e) {
49
+ fail(e);
50
+ }
51
+ }
52
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
53
+ if (env.hasError) throw env.error;
54
+ }
55
+ return next();
56
+ };
57
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
58
+ var e = new Error(message);
59
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
60
+ });
9
61
  Object.defineProperty(exports, "__esModule", { value: true });
10
62
  exports.ToolSelectionSyncHandler = exports.SelectionManager = void 0;
11
63
  const rxjs_1 = require("rxjs");
@@ -28,34 +80,41 @@ class SelectionManager {
28
80
  constructor(props) {
29
81
  this._imodelToolSelectionSyncHandlers = new Map();
30
82
  this._hiliteSetProviders = new Map();
31
- this._knownIModels = new Map();
83
+ this._knownIModels = new Set();
32
84
  this._currentSelection = new CurrentSelectionStorage();
33
85
  this._selectionChanges = new rxjs_1.Subject();
34
86
  this._listeners = [];
35
87
  this.selectionChange = new SelectionChangeEvent_1.SelectionChangeEvent();
36
88
  this.scopes = props.scopes;
37
- this._selectionStorage = props.selectionStorage ?? (0, unified_selection_1.createStorage)();
89
+ this.selectionStorage = props.selectionStorage ?? (0, unified_selection_1.createStorage)();
90
+ this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
38
91
  this._ownsStorage = props.selectionStorage === undefined;
39
- this._selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
92
+ this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
40
93
  this._selectionEventsSubscription = this.streamSelectionEvents();
41
94
  this._listeners.push(core_frontend_1.IModelConnection.onOpen.addListener((imodel) => {
42
- this._knownIModels.set(imodel.key, imodel);
95
+ this._knownIModels.add(imodel);
43
96
  }));
44
97
  this._listeners.push(core_frontend_1.IModelConnection.onClose.addListener((imodel) => {
45
98
  this.onConnectionClose(imodel);
46
99
  }));
47
100
  }
48
- dispose() {
101
+ [Symbol.dispose]() {
49
102
  this._selectionEventsSubscription.unsubscribe();
50
103
  this._listeners.forEach((dispose) => dispose());
51
104
  }
105
+ /** @deprecated in 5.0. Use [Symbol.dispose] instead. */
106
+ // istanbul ignore next
107
+ dispose() {
108
+ this[Symbol.dispose]();
109
+ }
52
110
  onConnectionClose(imodel) {
111
+ const imodelKey = this._imodelKeyFactory(imodel);
53
112
  this._hiliteSetProviders.delete(imodel);
54
- this._knownIModels.delete(imodel.key);
55
- this._currentSelection.clear(imodel.key);
113
+ this._knownIModels.delete(imodel);
114
+ this._currentSelection.clear(imodelKey);
56
115
  if (this._ownsStorage) {
57
116
  this.clearSelection("Connection Close Event", imodel);
58
- this._selectionStorage.clearStorage({ iModelKey: imodel.key });
117
+ this.selectionStorage.clearStorage({ imodelKey });
59
118
  }
60
119
  }
61
120
  /** @internal */
@@ -84,27 +143,30 @@ class SelectionManager {
84
143
  }
85
144
  else {
86
145
  this._imodelToolSelectionSyncHandlers.delete(imodel);
87
- registration.handler.dispose();
146
+ registration.handler[Symbol.dispose]();
88
147
  }
89
148
  }
90
149
  }
91
150
  }
92
151
  /**
93
- * Temporarily suspends tool selection synchronization until the returned `IDisposable`
152
+ * Temporarily suspends tool selection synchronization until the returned `Disposable`
94
153
  * is disposed.
95
154
  */
96
155
  suspendIModelToolSelectionSync(imodel) {
97
156
  const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
98
157
  if (!registration) {
99
- return { dispose: () => { } };
158
+ const noop = () => { };
159
+ return { [Symbol.dispose]: noop, dispose: noop };
100
160
  }
101
161
  const wasSuspended = registration.handler.isSuspended;
102
162
  registration.handler.isSuspended = true;
103
- return { dispose: () => (registration.handler.isSuspended = wasSuspended) };
163
+ const doDispose = () => (registration.handler.isSuspended = wasSuspended);
164
+ return { [Symbol.dispose]: doDispose, dispose: doDispose };
104
165
  }
105
166
  /** Get the selection levels currently stored in this manager for the specified imodel */
106
167
  getSelectionLevels(imodel) {
107
- return this._selectionStorage.getSelectionLevels({ iModelKey: imodel.key });
168
+ const imodelKey = this._imodelKeyFactory(imodel);
169
+ return this.selectionStorage.getSelectionLevels({ imodelKey });
108
170
  }
109
171
  /**
110
172
  * Get the selection currently stored in this manager
@@ -114,39 +176,39 @@ class SelectionManager {
114
176
  * latest selection after changes.
115
177
  */
116
178
  getSelection(imodel, level = 0) {
117
- return this._currentSelection.getSelection(imodel.key, level);
179
+ const imodelKey = this._imodelKeyFactory(imodel);
180
+ return this._currentSelection.getSelection(imodelKey, level);
118
181
  }
119
182
  handleEvent(evt) {
120
- if (!this._knownIModels.has(evt.imodel.key)) {
121
- this._knownIModels.set(evt.imodel.key, evt.imodel);
122
- }
183
+ const imodelKey = this._imodelKeyFactory(evt.imodel);
184
+ this._knownIModels.add(evt.imodel);
123
185
  switch (evt.changeType) {
124
186
  case SelectionChangeEvent_1.SelectionChangeType.Add:
125
- this._selectionStorage.addToSelection({
126
- iModelKey: evt.imodel.key,
187
+ this.selectionStorage.addToSelection({
188
+ imodelKey,
127
189
  source: evt.source,
128
190
  level: evt.level,
129
191
  selectables: keysToSelectable(evt.imodel, evt.keys),
130
192
  });
131
193
  break;
132
194
  case SelectionChangeEvent_1.SelectionChangeType.Remove:
133
- this._selectionStorage.removeFromSelection({
134
- iModelKey: evt.imodel.key,
195
+ this.selectionStorage.removeFromSelection({
196
+ imodelKey,
135
197
  source: evt.source,
136
198
  level: evt.level,
137
199
  selectables: keysToSelectable(evt.imodel, evt.keys),
138
200
  });
139
201
  break;
140
202
  case SelectionChangeEvent_1.SelectionChangeType.Replace:
141
- this._selectionStorage.replaceSelection({
142
- iModelKey: evt.imodel.key,
203
+ this.selectionStorage.replaceSelection({
204
+ imodelKey,
143
205
  source: evt.source,
144
206
  level: evt.level,
145
207
  selectables: keysToSelectable(evt.imodel, evt.keys),
146
208
  });
147
209
  break;
148
210
  case SelectionChangeEvent_1.SelectionChangeType.Clear:
149
- this._selectionStorage.clearSelection({ iModelKey: evt.imodel.key, source: evt.source, level: evt.level });
211
+ this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
150
212
  break;
151
213
  }
152
214
  }
@@ -293,9 +355,9 @@ class SelectionManager {
293
355
  streamSelectionEvents() {
294
356
  return this._selectionChanges
295
357
  .pipe((0, rxjs_1.mergeMap)((args) => {
296
- const currentSelectables = this._selectionStorage.getSelection({ iModelKey: args.imodelKey, level: args.level });
358
+ const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
297
359
  return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe((0, rxjs_1.mergeMap)(({ level, changedSelection }) => {
298
- const imodel = this._knownIModels.get(args.imodelKey);
360
+ const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
299
361
  // istanbul ignore if
300
362
  if (!imodel) {
301
363
  return rxjs_1.EMPTY;
@@ -318,66 +380,80 @@ class SelectionManager {
318
380
  }
319
381
  }
320
382
  exports.SelectionManager = SelectionManager;
383
+ function findIModel(set, imodelKeyFactory, key) {
384
+ for (const imodel of set) {
385
+ if (imodelKeyFactory(imodel) === key) {
386
+ return imodel;
387
+ }
388
+ }
389
+ return undefined;
390
+ }
321
391
  /** @internal */
322
392
  class ToolSelectionSyncHandler {
323
393
  constructor(imodel, logicalSelection) {
324
394
  this._selectionSourceName = "Tool";
325
395
  this._asyncsTracker = new presentation_common_1.AsyncTasksTracker();
326
396
  this.onToolSelectionChanged = async (ev) => {
327
- // ignore selection change event if the handler is suspended
328
- if (this.isSuspended) {
329
- return;
330
- }
331
- // this component only cares about its own imodel
332
- const imodel = ev.set.iModel;
333
- if (imodel !== this._imodel) {
334
- return;
335
- }
336
- // determine the level of selection changes
337
- // wip: may want to allow selecting at different levels?
338
- const selectionLevel = 0;
339
- let ids;
340
- switch (ev.type) {
341
- case core_frontend_1.SelectionSetEventType.Add:
342
- ids = ev.added;
343
- break;
344
- case core_frontend_1.SelectionSetEventType.Replace:
345
- ids = ev.set.elements;
346
- break;
347
- default:
348
- ids = ev.removed;
349
- break;
350
- }
351
- // we're always using scoped selection changer even if the scope is set to "element" - that
352
- // makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
353
- // we can't because otherwise our keys compare fails (presentation components load data with
354
- // concrete classes)
355
- const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0, SelectionScopesManager_1.createSelectionScopeProps)(this._logicalSelection.scopes.activeScope));
356
- // we know what to do immediately on `clear` events
357
- if (core_frontend_1.SelectionSetEventType.Clear === ev.type) {
358
- await changer.clear(selectionLevel);
359
- return;
360
- }
361
- const parsedIds = parseIds(ids);
362
- await (0, core_bentley_1.using)(this._asyncsTracker.trackAsyncTask(), async (_r) => {
397
+ const env_1 = { stack: [], error: void 0, hasError: false };
398
+ try {
399
+ // ignore selection change event if the handler is suspended
400
+ if (this.isSuspended) {
401
+ return;
402
+ }
403
+ // this component only cares about its own imodel
404
+ const imodel = ev.set.iModel;
405
+ if (imodel !== this._imodel) {
406
+ return;
407
+ }
408
+ // determine the level of selection changes
409
+ // wip: may want to allow selecting at different levels?
410
+ const selectionLevel = 0;
411
+ let ids;
412
+ switch (ev.type) {
413
+ case core_frontend_1.SelectionSetEventType.Add:
414
+ ids = ev.additions;
415
+ break;
416
+ case core_frontend_1.SelectionSetEventType.Replace:
417
+ ids = ev.set.active;
418
+ break;
419
+ default:
420
+ ids = ev.removals;
421
+ break;
422
+ }
423
+ // we're always using scoped selection changer even if the scope is set to "element" - that
424
+ // makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
425
+ // we can't because otherwise our keys compare fails (presentation components load data with
426
+ // concrete classes)
427
+ const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, (0, SelectionScopesManager_1.createSelectionScopeProps)(this._logicalSelection.scopes.activeScope));
428
+ const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
363
429
  switch (ev.type) {
364
430
  case core_frontend_1.SelectionSetEventType.Add:
365
- await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);
431
+ await changer.add(ids, selectionLevel);
366
432
  break;
367
433
  case core_frontend_1.SelectionSetEventType.Replace:
368
- await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);
434
+ await changer.replace(ids, selectionLevel);
369
435
  break;
370
436
  case core_frontend_1.SelectionSetEventType.Remove:
371
- await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
437
+ await changer.remove(ids, selectionLevel);
438
+ break;
439
+ case core_frontend_1.SelectionSetEventType.Clear:
440
+ await changer.clear(selectionLevel);
372
441
  break;
373
442
  }
374
- });
443
+ }
444
+ catch (e_1) {
445
+ env_1.error = e_1;
446
+ env_1.hasError = true;
447
+ }
448
+ finally {
449
+ __disposeResources(env_1);
450
+ }
375
451
  };
376
452
  this._imodel = imodel;
377
453
  this._logicalSelection = logicalSelection;
378
454
  this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
379
455
  }
380
- dispose() {
456
+ [Symbol.dispose]() {
381
457
  this._imodelToolSelectionListenerDisposeFunc();
382
458
  }
383
459
  /** note: used only it tests */
@@ -386,7 +462,7 @@ class ToolSelectionSyncHandler {
386
462
  }
387
463
  }
388
464
  exports.ToolSelectionSyncHandler = ToolSelectionSyncHandler;
389
- const parseIds = (ids) => {
465
+ const parseElementIds = (ids) => {
390
466
  let allPersistent = true;
391
467
  let allTransient = true;
392
468
  for (const id of core_bentley_1.Id64.iterable(ids)) {
@@ -421,12 +497,11 @@ const parseIds = (ids) => {
421
497
  }
422
498
  return { persistent: persistentElementIds, transient: transientElementIds };
423
499
  };
424
- function addTransientKeys(transientIds, keys) {
425
- for (const id of core_bentley_1.Id64.iterable(transientIds)) {
426
- keys.add({ className: unified_selection_1.TRANSIENT_ELEMENT_CLASSNAME, id });
500
+ function addKeys(target, className, ids) {
501
+ for (const id of core_bentley_1.Id64.iterable(ids)) {
502
+ target.add({ className, id });
427
503
  }
428
504
  }
429
- /** @internal */
430
505
  class ScopedSelectionChanger {
431
506
  constructor(name, imodel, manager, scope) {
432
507
  this.name = name;
@@ -437,21 +512,33 @@ class ScopedSelectionChanger {
437
512
  async clear(level) {
438
513
  this.manager.clearSelection(this.name, this.imodel, level);
439
514
  }
440
- async add(transientIds, persistentIds, level) {
441
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
442
- addTransientKeys(transientIds, keys);
515
+ async add(ids, level) {
516
+ const keys = await this.#computeSelection(ids);
443
517
  this.manager.addToSelection(this.name, this.imodel, keys, level);
444
518
  }
445
- async remove(transientIds, persistentIds, level) {
446
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
447
- addTransientKeys(transientIds, keys);
519
+ async remove(ids, level) {
520
+ const keys = await this.#computeSelection(ids);
448
521
  this.manager.removeFromSelection(this.name, this.imodel, keys, level);
449
522
  }
450
- async replace(transientIds, persistentIds, level) {
451
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
452
- addTransientKeys(transientIds, keys);
523
+ async replace(ids, level) {
524
+ const keys = await this.#computeSelection(ids);
453
525
  this.manager.replaceSelection(this.name, this.imodel, keys, level);
454
526
  }
527
+ async #computeSelection(ids) {
528
+ let keys = new presentation_common_1.KeySet();
529
+ if (ids.elements) {
530
+ const { persistent, transient } = parseElementIds(ids.elements);
531
+ keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
532
+ addKeys(keys, unified_selection_1.TRANSIENT_ELEMENT_CLASSNAME, transient);
533
+ }
534
+ if (ids.models) {
535
+ addKeys(keys, "BisCore.Model", ids.models);
536
+ }
537
+ if (ids.subcategories) {
538
+ addKeys(keys, "BisCore.SubCategory", ids.subcategories);
539
+ }
540
+ return keys;
541
+ }
455
542
  }
456
543
  /** Stores current selection in `KeySet` format per iModel. */
457
544
  class CurrentSelectionStorage {