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

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
@@ -42,9 +42,14 @@ export class SelectionHandler {
42
42
  * Destructor. Must be called before disposing this object to make sure it cleans
43
43
  * up correctly.
44
44
  */
45
- dispose() {
45
+ [Symbol.dispose]() {
46
46
  this._disposables.dispose();
47
47
  }
48
+ /** @deprecated in 5.0 Use [Symbol.dispose] instead. */
49
+ // istanbul ignore next
50
+ dispose() {
51
+ this[Symbol.dispose]();
52
+ }
48
53
  /** Called to check whether the event should be handled by this handler */
49
54
  shouldHandle(evt) {
50
55
  if (this.name === evt.source) {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAe,MAAM,qBAAqB,CAAC;AAiClE;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAkB3B;;OAEG;IACH,YAAY,KAA4B;QAmBxC;;;WAGG;QACO,uBAAkB,GAAG,CAAC,GAA6B,EAAE,QAA4B,EAAQ,EAAE;YACnG,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,OAAO;YACT,CAAC;YAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,C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AI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1F,CAAC;IAED;;;;OAIG;IACI,mBAAmB,CAAC,IAAU,EAAE,QAAgB,CAAC;QACtD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/F,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,IAAU,EAAE,QAAgB,CAAC;QACnD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5F,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,QAAgB,CAAC;QACrC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACpF,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { DisposableList, IDisposable } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { Keys, KeySet } from \"@itwin/presentation-common\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\nimport { SelectionChangeEventArgs, SelectionChangesListener } from \"./SelectionChangeEvent\";\r\nimport { SelectionManager } from \"./SelectionManager\";\r\n\r\n/**\r\n * Properties for creating a `SelectionHandler` instance.\r\n * @public\r\n */\r\nexport interface SelectionHandlerProps {\r\n /** SelectionManager used to store overall selection. */\r\n manager: SelectionManager;\r\n /** iModel connection the selection changes will be associated with. */\r\n imodel: IModelConnection;\r\n /**\r\n * Name of the selection handler. This is an identifier of what caused the\r\n * selection to change, set as `SelectionChangeEventArgs.source` when firing\r\n * selection change events. `SelectionHandler.shouldHandle` uses `name` to filter\r\n * events that it doesn't need to handle.\r\n */\r\n name: string;\r\n /**\r\n * ID of presentation ruleset used by the component using this handler. The ID is set as\r\n * `SelectionChangeEventArgs.rulesetId` when making selection changes and event\r\n * listeners can use or ignore this information.\r\n */\r\n rulesetId?: string;\r\n /** Callback function called when selection changes. */\r\n onSelect?: SelectionChangesListener;\r\n}\r\n\r\n/**\r\n * A class that handles selection changes and helps to change\r\n * internal the selection state.\r\n *\r\n * @public\r\n */\r\nexport class SelectionHandler implements IDisposable {\r\n private _inSelect: boolean;\r\n private _disposables: DisposableList;\r\n\r\n /** Selection manager used by this handler to manage selection */\r\n public readonly manager: SelectionManager;\r\n /** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */\r\n public name: string;\r\n /** iModel whose selection is being handled */\r\n public imodel: IModelConnection;\r\n /**\r\n * Id of a ruleset selection changes will be associated with.\r\n * @see `SelectionHandlerProps.rulesetId`\r\n */\r\n public rulesetId?: string;\r\n /** Callback function called when selection changes */\r\n public onSelect?: SelectionChangesListener;\r\n\r\n /**\r\n * Constructor.\r\n */\r\n constructor(props: SelectionHandlerProps) {\r\n this._inSelect = false;\r\n this.manager = props.manager;\r\n this._disposables = new DisposableList();\r\n this.name = props.name;\r\n this.rulesetId = props.rulesetId;\r\n this.imodel = props.imodel;\r\n this.onSelect = props.onSelect;\r\n this._disposables.add(this.manager.selectionChange.addListener(this.onSelectionChanged));\r\n }\r\n\r\n /**\r\n * Destructor. Must be called before disposing this object to make sure it cleans\r\n * up correctly.\r\n */\r\n public dispose(): void {\r\n this._disposables.dispose();\r\n }\r\n\r\n /**\r\n * Called when the selection changes. Handles this callback by first checking whether\r\n * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`\r\n */\r\n protected onSelectionChanged = (evt: SelectionChangeEventArgs, provider: ISelectionProvider): void => {\r\n if (!this.onSelect || !this.shouldHandle(evt)) {\r\n return;\r\n }\r\n\r\n this._inSelect = true;\r\n this.onSelect(evt, provider);\r\n this._inSelect = false;\r\n };\r\n\r\n /** Called to check whether the event should be handled by this handler */\r\n protected shouldHandle(evt: SelectionChangeEventArgs): boolean {\r\n if (this.name === evt.source) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Get selection levels for the imodel managed by this handler */\r\n public getSelectionLevels(): number[] {\r\n return this.manager.getSelectionLevels(this.imodel);\r\n }\r\n\r\n /**\r\n * Get selection for the imodel managed by this handler.\r\n * @param level Level of the selection to get. Defaults to 0.\r\n */\r\n public getSelection(level?: number): Readonly<KeySet> {\r\n return this.manager.getSelection(this.imodel, level);\r\n }\r\n\r\n /**\r\n * Add to selection.\r\n * @param keys The keys to add to selection.\r\n * @param level Level of the selection.\r\n */\r\n public addToSelection(keys: Keys, level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.addToSelection(this.name, this.imodel, keys, level, this.rulesetId);\r\n }\r\n\r\n /**\r\n * Remove from selection.\r\n * @param keys The keys to remove from selection.\r\n * @param level Level of the selection.\r\n */\r\n public removeFromSelection(keys: Keys, level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.removeFromSelection(this.name, this.imodel, keys, level, this.rulesetId);\r\n }\r\n\r\n /**\r\n * Change selection.\r\n * @param keys The keys indicating the new selection.\r\n * @param level Level of the selection.\r\n */\r\n public replaceSelection(keys: Keys, level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.replaceSelection(this.name, this.imodel, keys, level, this.rulesetId);\r\n }\r\n\r\n /**\r\n * Clear selection.\r\n * @param level Level of the selection.\r\n */\r\n public clearSelection(level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.clearSelection(this.name, this.imodel, level, this.rulesetId);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAiCrD;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAkB3B;;OAEG;IACH,YAAY,KAA4B;QAyBxC;;;WAGG;QACO,uBAAkB,GAAG,CAAC,GAA6B,EAAE,QAA4B,EAAQ,EAAE;YACnG,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,OAAO;YACT,CAAC;YAED,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAC7B,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC;QApCA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,IAAI,cAAc,EAAE,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,QAAQ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AAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/F,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,IAAU,EAAE,QAAgB,CAAC;QACnD,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5F,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,QAAgB,CAAC;QACrC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACpF,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { DisposableList } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { Keys, KeySet } from \"@itwin/presentation-common\";\nimport { ISelectionProvider } from \"./ISelectionProvider\";\nimport { SelectionChangeEventArgs, SelectionChangesListener } from \"./SelectionChangeEvent\";\nimport { SelectionManager } from \"./SelectionManager\";\n\n/**\n * Properties for creating a `SelectionHandler` instance.\n * @public\n */\nexport interface SelectionHandlerProps {\n /** SelectionManager used to store overall selection. */\n manager: SelectionManager;\n /** iModel connection the selection changes will be associated with. */\n imodel: IModelConnection;\n /**\n * Name of the selection handler. This is an identifier of what caused the\n * selection to change, set as `SelectionChangeEventArgs.source` when firing\n * selection change events. `SelectionHandler.shouldHandle` uses `name` to filter\n * events that it doesn't need to handle.\n */\n name: string;\n /**\n * ID of presentation ruleset used by the component using this handler. The ID is set as\n * `SelectionChangeEventArgs.rulesetId` when making selection changes and event\n * listeners can use or ignore this information.\n */\n rulesetId?: string;\n /** Callback function called when selection changes. */\n onSelect?: SelectionChangesListener;\n}\n\n/**\n * A class that handles selection changes and helps to change\n * internal the selection state.\n *\n * @public\n */\nexport class SelectionHandler implements Disposable {\n private _inSelect: boolean;\n private _disposables: DisposableList;\n\n /** Selection manager used by this handler to manage selection */\n public readonly manager: SelectionManager;\n /** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */\n public name: string;\n /** iModel whose selection is being handled */\n public imodel: IModelConnection;\n /**\n * Id of a ruleset selection changes will be associated with.\n * @see `SelectionHandlerProps.rulesetId`\n */\n public rulesetId?: string;\n /** Callback function called when selection changes */\n public onSelect?: SelectionChangesListener;\n\n /**\n * Constructor.\n */\n constructor(props: SelectionHandlerProps) {\n this._inSelect = false;\n this.manager = props.manager;\n this._disposables = new DisposableList();\n this.name = props.name;\n this.rulesetId = props.rulesetId;\n this.imodel = props.imodel;\n this.onSelect = props.onSelect;\n this._disposables.add(this.manager.selectionChange.addListener(this.onSelectionChanged));\n }\n\n /**\n * Destructor. Must be called before disposing this object to make sure it cleans\n * up correctly.\n */\n public [Symbol.dispose](): void {\n this._disposables.dispose();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n // istanbul ignore next\n public dispose() {\n this[Symbol.dispose]();\n }\n\n /**\n * Called when the selection changes. Handles this callback by first checking whether\n * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`\n */\n protected onSelectionChanged = (evt: SelectionChangeEventArgs, provider: ISelectionProvider): void => {\n if (!this.onSelect || !this.shouldHandle(evt)) {\n return;\n }\n\n this._inSelect = true;\n this.onSelect(evt, provider);\n this._inSelect = false;\n };\n\n /** Called to check whether the event should be handled by this handler */\n protected shouldHandle(evt: SelectionChangeEventArgs): boolean {\n if (this.name === evt.source) {\n return false;\n }\n return true;\n }\n\n /** Get selection levels for the imodel managed by this handler */\n public getSelectionLevels(): number[] {\n return this.manager.getSelectionLevels(this.imodel);\n }\n\n /**\n * Get selection for the imodel managed by this handler.\n * @param level Level of the selection to get. Defaults to 0.\n */\n public getSelection(level?: number): Readonly<KeySet> {\n return this.manager.getSelection(this.imodel, level);\n }\n\n /**\n * Add to selection.\n * @param keys The keys to add to selection.\n * @param level Level of the selection.\n */\n public addToSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.addToSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Remove from selection.\n * @param keys The keys to remove from selection.\n * @param level Level of the selection.\n */\n public removeFromSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.removeFromSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Change selection.\n * @param keys The keys indicating the new selection.\n * @param level Level of the selection.\n */\n public replaceSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.replaceSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Clear selection.\n * @param level Level of the selection.\n */\n public clearSelection(level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.clearSelection(this.name, this.imodel, level, this.rulesetId);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,uBAAuB;IACvB,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Helper class for working with selection.\r\n * @public\r\n */\r\nexport class SelectionHelper {\r\n // istanbul ignore next\r\n private constructor() {}\r\n\r\n /**\r\n * Re-map the given keyset for selection. This means all instance node keys get converted\r\n * to instance keys, because in that case we want to select instances instead of nodes. All\r\n * other types of keys ar left as is.\r\n */\r\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\r\n const result = new Array<Key>();\r\n keys.forEach((key: Key) => {\r\n if (Key.isNodeKey(key)) {\r\n if (NodeKey.isInstancesNodeKey(key)) {\r\n result.push(...key.instanceKeys);\r\n } else {\r\n result.push(key);\r\n }\r\n } else {\r\n result.push(key);\r\n }\r\n });\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,uBAAuB;IACvB,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\n\n/**\n * Helper class for working with selection.\n * @public\n */\nexport class SelectionHelper {\n // istanbul ignore next\n private constructor() {}\n\n /**\n * Re-map the given keyset for selection. This means all instance node keys get converted\n * to instance keys, because in that case we want to select instances instead of nodes. All\n * other types of keys ar left as is.\n */\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\n const result = new Array<Key>();\n keys.forEach((key: Key) => {\n if (Key.isNodeKey(key)) {\n if (NodeKey.isInstancesNodeKey(key)) {\n result.push(...key.instanceKeys);\n } else {\n result.push(key);\n }\n } else {\n result.push(key);\n }\n });\n return result;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module UnifiedSelection
3
3
  */
4
- import { Id64Arg, IDisposable } from "@itwin/core-bentley";
4
+ import { Id64Arg } from "@itwin/core-bentley";
5
5
  import { IModelConnection } from "@itwin/core-frontend";
6
6
  import { Keys, KeySet, SelectionScope, SelectionScopeProps } from "@itwin/presentation-common";
7
7
  import { SelectionStorage } from "@itwin/unified-selection";
@@ -21,13 +21,21 @@ export interface SelectionManagerProps {
21
21
  * and maintains storage.
22
22
  */
23
23
  selectionStorage?: SelectionStorage;
24
+ /**
25
+ * An optional function that returns a key for the given iModel. The key is what "glues" iModel selection
26
+ * changes made in `selectionStorage`, where iModels are identified by key, and `SelectionManager`, where
27
+ * iModels are specified as `IModelConnection`.
28
+ *
29
+ * If not provided, [IModelConnection.key]($core-frontend) or [IModelConnection.name]($core-frontend) is used.
30
+ */
31
+ imodelKeyFactory?: (imodel: IModelConnection) => string;
24
32
  }
25
33
  /**
26
34
  * The selection manager which stores the overall selection.
27
35
  * @public
28
36
  */
29
- export declare class SelectionManager implements ISelectionProvider {
30
- private _selectionStorage;
37
+ export declare class SelectionManager implements ISelectionProvider, Disposable {
38
+ private _imodelKeyFactory;
31
39
  private _imodelToolSelectionSyncHandlers;
32
40
  private _hiliteSetProviders;
33
41
  private _ownsStorage;
@@ -36,6 +44,11 @@ export declare class SelectionManager implements ISelectionProvider {
36
44
  private _selectionChanges;
37
45
  private _selectionEventsSubscription;
38
46
  private _listeners;
47
+ /**
48
+ * Underlying selection storage used by this selection manager. Ideally, consumers should use
49
+ * the storage directly instead of using this manager to manipulate selection.
50
+ */
51
+ readonly selectionStorage: SelectionStorage;
39
52
  /** An event which gets broadcasted on selection changes */
40
53
  readonly selectionChange: SelectionChangeEvent;
41
54
  /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
@@ -44,6 +57,8 @@ export declare class SelectionManager implements ISelectionProvider {
44
57
  * Creates an instance of SelectionManager.
45
58
  */
46
59
  constructor(props: SelectionManagerProps);
60
+ [Symbol.dispose](): void;
61
+ /** @deprecated in 5.0. Use [Symbol.dispose] instead. */
47
62
  dispose(): void;
48
63
  private onConnectionClose;
49
64
  /** @internal */
@@ -53,10 +68,13 @@ export declare class SelectionManager implements ISelectionProvider {
53
68
  */
54
69
  setSyncWithIModelToolSelection(imodel: IModelConnection, sync?: boolean): void;
55
70
  /**
56
- * Temporarily suspends tool selection synchronization until the returned `IDisposable`
71
+ * Temporarily suspends tool selection synchronization until the returned `Disposable`
57
72
  * is disposed.
58
73
  */
59
- suspendIModelToolSelectionSync(imodel: IModelConnection): IDisposable;
74
+ suspendIModelToolSelectionSync(imodel: IModelConnection): {
75
+ [Symbol.dispose]: () => void;
76
+ dispose: () => void;
77
+ };
60
78
  /** Get the selection levels currently stored in this manager for the specified imodel */
61
79
  getSelectionLevels(imodel: IModelConnection): number[];
62
80
  /**
@@ -147,7 +165,7 @@ export declare class SelectionManager implements ISelectionProvider {
147
165
  private streamSelectionEvents;
148
166
  }
149
167
  /** @internal */
150
- export declare class ToolSelectionSyncHandler implements IDisposable {
168
+ export declare class ToolSelectionSyncHandler implements Disposable {
151
169
  private _selectionSourceName;
152
170
  private _logicalSelection;
153
171
  private _imodel;
@@ -155,7 +173,7 @@ export declare class ToolSelectionSyncHandler implements IDisposable {
155
173
  private _asyncsTracker;
156
174
  isSuspended?: boolean;
157
175
  constructor(imodel: IModelConnection, logicalSelection: SelectionManager);
158
- dispose(): void;
176
+ [Symbol.dispose](): void;
159
177
  /** note: used only it tests */
160
178
  get pendingAsyncs(): Set<string>;
161
179
  private onToolSelectionChanged;
@@ -1 +1 @@
1
- {"version":3,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AAC;gBAEV,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB;IAMxE,CAAC,MAAM,CAAC,OAAO,CAAC;IAIvB,+BAA+B;IAC/B,IAAW,aAAa,gBAEvB;IAED,OAAO,CAAC,sBAAsB,CAuD5B;CACH"}
@@ -5,8 +5,60 @@
5
5
  /** @packageDocumentation
6
6
  * @module UnifiedSelection
7
7
  */
8
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
9
+ if (value !== null && value !== void 0) {
10
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
11
+ var dispose, inner;
12
+ if (async) {
13
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
14
+ dispose = value[Symbol.asyncDispose];
15
+ }
16
+ if (dispose === void 0) {
17
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
18
+ dispose = value[Symbol.dispose];
19
+ if (async) inner = dispose;
20
+ }
21
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
22
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
23
+ env.stack.push({ value: value, dispose: dispose, async: async });
24
+ }
25
+ else if (async) {
26
+ env.stack.push({ async: true });
27
+ }
28
+ return value;
29
+ };
30
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
31
+ return function (env) {
32
+ function fail(e) {
33
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
34
+ env.hasError = true;
35
+ }
36
+ var r, s = 0;
37
+ function next() {
38
+ while (r = env.stack.pop()) {
39
+ try {
40
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
41
+ if (r.dispose) {
42
+ var result = r.dispose.call(r.value);
43
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
44
+ }
45
+ else s |= 1;
46
+ }
47
+ catch (e) {
48
+ fail(e);
49
+ }
50
+ }
51
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
52
+ if (env.hasError) throw env.error;
53
+ }
54
+ return next();
55
+ };
56
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
57
+ var e = new Error(message);
58
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
59
+ });
8
60
  import { defer, EMPTY, mergeMap, of, Subject, takeUntil, tap } from "rxjs";
9
- import { Id64, using } from "@itwin/core-bentley";
61
+ import { Id64 } from "@itwin/core-bentley";
10
62
  import { IModelConnection, SelectionSetEventType } from "@itwin/core-frontend";
11
63
  import { AsyncTasksTracker, KeySet, NodeKey } from "@itwin/presentation-common";
12
64
  import { createStorage, TRANSIENT_ELEMENT_CLASSNAME, } from "@itwin/unified-selection";
@@ -25,34 +77,41 @@ export class SelectionManager {
25
77
  constructor(props) {
26
78
  this._imodelToolSelectionSyncHandlers = new Map();
27
79
  this._hiliteSetProviders = new Map();
28
- this._knownIModels = new Map();
80
+ this._knownIModels = new Set();
29
81
  this._currentSelection = new CurrentSelectionStorage();
30
82
  this._selectionChanges = new Subject();
31
83
  this._listeners = [];
32
84
  this.selectionChange = new SelectionChangeEvent();
33
85
  this.scopes = props.scopes;
34
- this._selectionStorage = props.selectionStorage ?? createStorage();
86
+ this.selectionStorage = props.selectionStorage ?? createStorage();
87
+ this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
35
88
  this._ownsStorage = props.selectionStorage === undefined;
36
- this._selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
89
+ this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
37
90
  this._selectionEventsSubscription = this.streamSelectionEvents();
38
91
  this._listeners.push(IModelConnection.onOpen.addListener((imodel) => {
39
- this._knownIModels.set(imodel.key, imodel);
92
+ this._knownIModels.add(imodel);
40
93
  }));
41
94
  this._listeners.push(IModelConnection.onClose.addListener((imodel) => {
42
95
  this.onConnectionClose(imodel);
43
96
  }));
44
97
  }
45
- dispose() {
98
+ [Symbol.dispose]() {
46
99
  this._selectionEventsSubscription.unsubscribe();
47
100
  this._listeners.forEach((dispose) => dispose());
48
101
  }
102
+ /** @deprecated in 5.0. Use [Symbol.dispose] instead. */
103
+ // istanbul ignore next
104
+ dispose() {
105
+ this[Symbol.dispose]();
106
+ }
49
107
  onConnectionClose(imodel) {
108
+ const imodelKey = this._imodelKeyFactory(imodel);
50
109
  this._hiliteSetProviders.delete(imodel);
51
- this._knownIModels.delete(imodel.key);
52
- this._currentSelection.clear(imodel.key);
110
+ this._knownIModels.delete(imodel);
111
+ this._currentSelection.clear(imodelKey);
53
112
  if (this._ownsStorage) {
54
113
  this.clearSelection("Connection Close Event", imodel);
55
- this._selectionStorage.clearStorage({ iModelKey: imodel.key });
114
+ this.selectionStorage.clearStorage({ imodelKey });
56
115
  }
57
116
  }
58
117
  /** @internal */
@@ -81,27 +140,30 @@ export class SelectionManager {
81
140
  }
82
141
  else {
83
142
  this._imodelToolSelectionSyncHandlers.delete(imodel);
84
- registration.handler.dispose();
143
+ registration.handler[Symbol.dispose]();
85
144
  }
86
145
  }
87
146
  }
88
147
  }
89
148
  /**
90
- * Temporarily suspends tool selection synchronization until the returned `IDisposable`
149
+ * Temporarily suspends tool selection synchronization until the returned `Disposable`
91
150
  * is disposed.
92
151
  */
93
152
  suspendIModelToolSelectionSync(imodel) {
94
153
  const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
95
154
  if (!registration) {
96
- return { dispose: () => { } };
155
+ const noop = () => { };
156
+ return { [Symbol.dispose]: noop, dispose: noop };
97
157
  }
98
158
  const wasSuspended = registration.handler.isSuspended;
99
159
  registration.handler.isSuspended = true;
100
- return { dispose: () => (registration.handler.isSuspended = wasSuspended) };
160
+ const doDispose = () => (registration.handler.isSuspended = wasSuspended);
161
+ return { [Symbol.dispose]: doDispose, dispose: doDispose };
101
162
  }
102
163
  /** Get the selection levels currently stored in this manager for the specified imodel */
103
164
  getSelectionLevels(imodel) {
104
- return this._selectionStorage.getSelectionLevels({ iModelKey: imodel.key });
165
+ const imodelKey = this._imodelKeyFactory(imodel);
166
+ return this.selectionStorage.getSelectionLevels({ imodelKey });
105
167
  }
106
168
  /**
107
169
  * Get the selection currently stored in this manager
@@ -111,39 +173,39 @@ export class SelectionManager {
111
173
  * latest selection after changes.
112
174
  */
113
175
  getSelection(imodel, level = 0) {
114
- return this._currentSelection.getSelection(imodel.key, level);
176
+ const imodelKey = this._imodelKeyFactory(imodel);
177
+ return this._currentSelection.getSelection(imodelKey, level);
115
178
  }
116
179
  handleEvent(evt) {
117
- if (!this._knownIModels.has(evt.imodel.key)) {
118
- this._knownIModels.set(evt.imodel.key, evt.imodel);
119
- }
180
+ const imodelKey = this._imodelKeyFactory(evt.imodel);
181
+ this._knownIModels.add(evt.imodel);
120
182
  switch (evt.changeType) {
121
183
  case SelectionChangeType.Add:
122
- this._selectionStorage.addToSelection({
123
- iModelKey: evt.imodel.key,
184
+ this.selectionStorage.addToSelection({
185
+ imodelKey,
124
186
  source: evt.source,
125
187
  level: evt.level,
126
188
  selectables: keysToSelectable(evt.imodel, evt.keys),
127
189
  });
128
190
  break;
129
191
  case SelectionChangeType.Remove:
130
- this._selectionStorage.removeFromSelection({
131
- iModelKey: evt.imodel.key,
192
+ this.selectionStorage.removeFromSelection({
193
+ imodelKey,
132
194
  source: evt.source,
133
195
  level: evt.level,
134
196
  selectables: keysToSelectable(evt.imodel, evt.keys),
135
197
  });
136
198
  break;
137
199
  case SelectionChangeType.Replace:
138
- this._selectionStorage.replaceSelection({
139
- iModelKey: evt.imodel.key,
200
+ this.selectionStorage.replaceSelection({
201
+ imodelKey,
140
202
  source: evt.source,
141
203
  level: evt.level,
142
204
  selectables: keysToSelectable(evt.imodel, evt.keys),
143
205
  });
144
206
  break;
145
207
  case SelectionChangeType.Clear:
146
- this._selectionStorage.clearSelection({ iModelKey: evt.imodel.key, source: evt.source, level: evt.level });
208
+ this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
147
209
  break;
148
210
  }
149
211
  }
@@ -290,9 +352,9 @@ export class SelectionManager {
290
352
  streamSelectionEvents() {
291
353
  return this._selectionChanges
292
354
  .pipe(mergeMap((args) => {
293
- const currentSelectables = this._selectionStorage.getSelection({ iModelKey: args.imodelKey, level: args.level });
355
+ const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
294
356
  return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(mergeMap(({ level, changedSelection }) => {
295
- const imodel = this._knownIModels.get(args.imodelKey);
357
+ const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
296
358
  // istanbul ignore if
297
359
  if (!imodel) {
298
360
  return EMPTY;
@@ -314,66 +376,80 @@ export class SelectionManager {
314
376
  });
315
377
  }
316
378
  }
379
+ function findIModel(set, imodelKeyFactory, key) {
380
+ for (const imodel of set) {
381
+ if (imodelKeyFactory(imodel) === key) {
382
+ return imodel;
383
+ }
384
+ }
385
+ return undefined;
386
+ }
317
387
  /** @internal */
318
388
  export class ToolSelectionSyncHandler {
319
389
  constructor(imodel, logicalSelection) {
320
390
  this._selectionSourceName = "Tool";
321
391
  this._asyncsTracker = new AsyncTasksTracker();
322
392
  this.onToolSelectionChanged = async (ev) => {
323
- // ignore selection change event if the handler is suspended
324
- if (this.isSuspended) {
325
- return;
326
- }
327
- // this component only cares about its own imodel
328
- const imodel = ev.set.iModel;
329
- if (imodel !== this._imodel) {
330
- return;
331
- }
332
- // determine the level of selection changes
333
- // wip: may want to allow selecting at different levels?
334
- const selectionLevel = 0;
335
- let ids;
336
- switch (ev.type) {
337
- case SelectionSetEventType.Add:
338
- ids = ev.added;
339
- break;
340
- case SelectionSetEventType.Replace:
341
- ids = ev.set.elements;
342
- break;
343
- default:
344
- ids = ev.removed;
345
- break;
346
- }
347
- // we're always using scoped selection changer even if the scope is set to "element" - that
348
- // makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
349
- // we can't because otherwise our keys compare fails (presentation components load data with
350
- // concrete classes)
351
- const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
352
- // we know what to do immediately on `clear` events
353
- if (SelectionSetEventType.Clear === ev.type) {
354
- await changer.clear(selectionLevel);
355
- return;
356
- }
357
- const parsedIds = parseIds(ids);
358
- await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {
393
+ const env_1 = { stack: [], error: void 0, hasError: false };
394
+ try {
395
+ // ignore selection change event if the handler is suspended
396
+ if (this.isSuspended) {
397
+ return;
398
+ }
399
+ // this component only cares about its own imodel
400
+ const imodel = ev.set.iModel;
401
+ if (imodel !== this._imodel) {
402
+ return;
403
+ }
404
+ // determine the level of selection changes
405
+ // wip: may want to allow selecting at different levels?
406
+ const selectionLevel = 0;
407
+ let ids;
408
+ switch (ev.type) {
409
+ case SelectionSetEventType.Add:
410
+ ids = ev.additions;
411
+ break;
412
+ case SelectionSetEventType.Replace:
413
+ ids = ev.set.active;
414
+ break;
415
+ default:
416
+ ids = ev.removals;
417
+ break;
418
+ }
419
+ // we're always using scoped selection changer even if the scope is set to "element" - that
420
+ // makes sure we're adding to selection keys with concrete classes and not "BisCore:Element", which
421
+ // we can't because otherwise our keys compare fails (presentation components load data with
422
+ // concrete classes)
423
+ const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
424
+ const _r = __addDisposableResource(env_1, this._asyncsTracker.trackAsyncTask(), false);
359
425
  switch (ev.type) {
360
426
  case SelectionSetEventType.Add:
361
- await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);
427
+ await changer.add(ids, selectionLevel);
362
428
  break;
363
429
  case SelectionSetEventType.Replace:
364
- await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);
430
+ await changer.replace(ids, selectionLevel);
365
431
  break;
366
432
  case SelectionSetEventType.Remove:
367
- await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
433
+ await changer.remove(ids, selectionLevel);
434
+ break;
435
+ case SelectionSetEventType.Clear:
436
+ await changer.clear(selectionLevel);
368
437
  break;
369
438
  }
370
- });
439
+ }
440
+ catch (e_1) {
441
+ env_1.error = e_1;
442
+ env_1.hasError = true;
443
+ }
444
+ finally {
445
+ __disposeResources(env_1);
446
+ }
371
447
  };
372
448
  this._imodel = imodel;
373
449
  this._logicalSelection = logicalSelection;
374
450
  this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);
375
451
  }
376
- dispose() {
452
+ [Symbol.dispose]() {
377
453
  this._imodelToolSelectionListenerDisposeFunc();
378
454
  }
379
455
  /** note: used only it tests */
@@ -381,7 +457,7 @@ export class ToolSelectionSyncHandler {
381
457
  return this._asyncsTracker.pendingAsyncs;
382
458
  }
383
459
  }
384
- const parseIds = (ids) => {
460
+ const parseElementIds = (ids) => {
385
461
  let allPersistent = true;
386
462
  let allTransient = true;
387
463
  for (const id of Id64.iterable(ids)) {
@@ -416,12 +492,11 @@ const parseIds = (ids) => {
416
492
  }
417
493
  return { persistent: persistentElementIds, transient: transientElementIds };
418
494
  };
419
- function addTransientKeys(transientIds, keys) {
420
- for (const id of Id64.iterable(transientIds)) {
421
- keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });
495
+ function addKeys(target, className, ids) {
496
+ for (const id of Id64.iterable(ids)) {
497
+ target.add({ className, id });
422
498
  }
423
499
  }
424
- /** @internal */
425
500
  class ScopedSelectionChanger {
426
501
  constructor(name, imodel, manager, scope) {
427
502
  this.name = name;
@@ -432,21 +507,33 @@ class ScopedSelectionChanger {
432
507
  async clear(level) {
433
508
  this.manager.clearSelection(this.name, this.imodel, level);
434
509
  }
435
- async add(transientIds, persistentIds, level) {
436
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
437
- addTransientKeys(transientIds, keys);
510
+ async add(ids, level) {
511
+ const keys = await this.#computeSelection(ids);
438
512
  this.manager.addToSelection(this.name, this.imodel, keys, level);
439
513
  }
440
- async remove(transientIds, persistentIds, level) {
441
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
442
- addTransientKeys(transientIds, keys);
514
+ async remove(ids, level) {
515
+ const keys = await this.#computeSelection(ids);
443
516
  this.manager.removeFromSelection(this.name, this.imodel, keys, level);
444
517
  }
445
- async replace(transientIds, persistentIds, level) {
446
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
447
- addTransientKeys(transientIds, keys);
518
+ async replace(ids, level) {
519
+ const keys = await this.#computeSelection(ids);
448
520
  this.manager.replaceSelection(this.name, this.imodel, keys, level);
449
521
  }
522
+ async #computeSelection(ids) {
523
+ let keys = new KeySet();
524
+ if (ids.elements) {
525
+ const { persistent, transient } = parseElementIds(ids.elements);
526
+ keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
527
+ addKeys(keys, TRANSIENT_ELEMENT_CLASSNAME, transient);
528
+ }
529
+ if (ids.models) {
530
+ addKeys(keys, "BisCore.Model", ids.models);
531
+ }
532
+ if (ids.subcategories) {
533
+ addKeys(keys, "BisCore.SubCategory", ids.subcategories);
534
+ }
535
+ return keys;
536
+ }
450
537
  }
451
538
  /** Stores current selection in `KeySet` format per iModel. */
452
539
  class CurrentSelectionStorage {