@itwin/presentation-frontend 4.5.0-dev.9 → 4.6.0-dev.1

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 (124) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +1 -1
  4. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
  5. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +10 -6
  6. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  7. package/lib/cjs/presentation-frontend/Diagnostics.d.ts.map +1 -1
  8. package/lib/cjs/presentation-frontend/Diagnostics.js +18 -13
  9. package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
  10. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +3 -3
  11. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  12. package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  13. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +3 -3
  14. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  15. package/lib/cjs/presentation-frontend/LocalizationHelper.js +3 -3
  16. package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
  17. package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
  18. package/lib/cjs/presentation-frontend/Presentation.js +26 -16
  19. package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
  20. package/lib/cjs/presentation-frontend/PresentationManager.d.ts +84 -21
  21. package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
  22. package/lib/cjs/presentation-frontend/PresentationManager.js +245 -154
  23. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  24. package/lib/cjs/presentation-frontend/RulesetManager.d.ts.map +1 -1
  25. package/lib/cjs/presentation-frontend/RulesetManager.js +11 -7
  26. package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
  27. package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
  28. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +53 -31
  29. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  30. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts +30 -0
  31. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -0
  32. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js +117 -0
  33. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -0
  34. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +33 -4
  35. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  36. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +179 -74
  37. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  38. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
  39. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +54 -25
  40. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  41. package/lib/cjs/presentation-frontend/selection/HiliteRules.json +172 -172
  42. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
  43. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +23 -13
  44. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  45. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +3 -3
  46. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  47. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
  48. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +3 -3
  49. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  50. package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
  51. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +15 -9
  52. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  53. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  54. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +7 -5
  55. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  56. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
  57. package/lib/cjs/presentation-frontend/selection/SelectionManager.js +31 -16
  58. package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
  59. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
  60. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +25 -14
  61. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  62. package/lib/cjs/presentation-frontend.js +3 -3
  63. package/lib/cjs/presentation-frontend.js.map +1 -1
  64. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts.map +1 -1
  65. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +10 -6
  66. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  67. package/lib/esm/presentation-frontend/Diagnostics.d.ts.map +1 -1
  68. package/lib/esm/presentation-frontend/Diagnostics.js +18 -13
  69. package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
  70. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +3 -3
  71. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  72. package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  73. package/lib/esm/presentation-frontend/IpcRequestsHandler.js +3 -3
  74. package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  75. package/lib/esm/presentation-frontend/LocalizationHelper.js +3 -3
  76. package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
  77. package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
  78. package/lib/esm/presentation-frontend/Presentation.js +26 -16
  79. package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
  80. package/lib/esm/presentation-frontend/PresentationManager.d.ts +84 -21
  81. package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
  82. package/lib/esm/presentation-frontend/PresentationManager.js +244 -152
  83. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  84. package/lib/esm/presentation-frontend/RulesetManager.d.ts.map +1 -1
  85. package/lib/esm/presentation-frontend/RulesetManager.js +11 -7
  86. package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
  87. package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts.map +1 -1
  88. package/lib/esm/presentation-frontend/RulesetVariablesManager.js +53 -31
  89. package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  90. package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts +30 -0
  91. package/lib/esm/presentation-frontend/StreamedResponseGenerator.d.ts.map +1 -0
  92. package/lib/esm/presentation-frontend/StreamedResponseGenerator.js +113 -0
  93. package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -0
  94. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +33 -4
  95. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  96. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +179 -74
  97. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  98. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts.map +1 -1
  99. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +54 -25
  100. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  101. package/lib/esm/presentation-frontend/selection/HiliteRules.json +172 -172
  102. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts.map +1 -1
  103. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +24 -14
  104. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  105. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +3 -3
  106. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  107. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts.map +1 -1
  108. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +3 -3
  109. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  110. package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts.map +1 -1
  111. package/lib/esm/presentation-frontend/selection/SelectionHandler.js +15 -9
  112. package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  113. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  114. package/lib/esm/presentation-frontend/selection/SelectionHelper.js +7 -5
  115. package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  116. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
  117. package/lib/esm/presentation-frontend/selection/SelectionManager.js +31 -16
  118. package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
  119. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts.map +1 -1
  120. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +25 -14
  121. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  122. package/lib/esm/presentation-frontend.js +3 -3
  123. package/lib/esm/presentation-frontend.js.map +1 -1
  124. package/package.json +19 -16
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAe,MAAM,qBAAqB,CAAC;AAiClE;;;;;G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F","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 // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected onSelectionChanged = (evt: SelectionChangeEventArgs, provider: ISelectionProvider): void => {\r\n if (!this.onSelect || !this.shouldHandle(evt))\r\n return;\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 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 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 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 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 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;AAiClE;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAkB3B;;OAEG;IACH,YAAY,KAA4B;QAmBxC;;;WAGG;QACH,gEAAgE;QACtD,uBAAkB,GAAG,CAAC,GAA6B,EAAE,QAA4B,EAAQ,EAAE;YACnG,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE;gBAC7C,OAAO;aACR;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;QA/BA,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAA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IAC1F,CAAC;IAED;;;;OAIG;IACI,mBAAmB,CAAC,IAAU,EAAE,QAAgB,CAAC;QACtD,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,OAAO;SACR;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;YAClB,OAAO;SACR;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;YAClB,OAAO;SACR;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, IDisposable } 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 IDisposable {\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 dispose(): void {\n this._disposables.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 // eslint-disable-next-line @typescript-eslint/naming-convention\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.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,qBAAa,eAAe;IAG1B,OAAO;IAEP;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;CAe/D"}
1
+ {"version":3,"file":"SelectionHelper.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,qBAAa,eAAe;IAE1B,OAAO;IAEP;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;CAe/D"}
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  /** @packageDocumentation
6
6
  * @module UnifiedSelection
7
7
  */
@@ -22,10 +22,12 @@ export class SelectionHelper {
22
22
  const result = new Array();
23
23
  keys.forEach((key) => {
24
24
  if (Key.isNodeKey(key)) {
25
- if (NodeKey.isInstancesNodeKey(key))
25
+ if (NodeKey.isInstancesNodeKey(key)) {
26
26
  result.push(...key.instanceKeys);
27
- else
27
+ }
28
+ else {
28
29
  result.push(key);
30
+ }
29
31
  }
30
32
  else {
31
33
  result.push(key);
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAE1B,uBAAuB;IACvB,gBAAwB,CAAC;IAEzB;;;;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;gBACtB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;;oBAEjC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF","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\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 } else {\r\n result.push(key);\r\n }\r\n });\r\n return result;\r\n }\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;gBACtB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE;oBACnC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;iBAClC;qBAAM;oBACL,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;iBAClB;aACF;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;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 +1 @@
1
- {"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,OAAO,EAAa,WAAW,EAAS,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAA4C,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAqB,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAClH,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAiD,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAE7F;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,oGAAoG;IACpG,MAAM,EAAE,sBAAsB,CAAC;CAChC;AAED;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,kBAAkB;IACzD,OAAO,CAAC,sBAAsB,CAAmD;IACjF,OAAO,CAAC,gCAAgC,CAA+F;IACvI,OAAO,CAAC,mBAAmB,CAAkD;IAE7E,2DAA2D;IAC3D,SAAgB,eAAe,EAAE,oBAAoB,CAAC;IAEtD,kGAAkG;IAClG,SAAgB,MAAM,EAAE,sBAAsB,CAAC;IAE/C;;OAEG;gBACS,KAAK,EAAE,qBAAqB;IAQxC,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,YAAY;IASpB,gBAAgB;IAET,2BAA2B,CAAC,MAAM,EAAE,gBAAgB;IAE3D;;OAEG;IACI,8BAA8B,CAAC,MAAM,EAAE,gBAAgB,EAAE,IAAI,UAAO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gBAAgB,EACxB,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,mBAAmB,GAAG,cAAc,GAAG,MAAM,EACpD,KAAK,GAAE,MAAU,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC;IAKhB;;;OAGG;IACU,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAIvE;;;OAGG;IACI,oBAAoB,CAAC,MAAM,EAAE,gBAAgB;IAIpD,OAAO,CAAC,oBAAoB;CAQ7B;AAwCD,gBAAgB;AAChB,eAAO,MAAM,2BAA2B,eAAe,CAAC;AAExD,gBAAgB;AAChB,qBAAa,wBAAyB,YAAW,WAAW;IAC1D,OAAO,CAAC,oBAAoB,CAAU;IACtC,OAAO,CAAC,iBAAiB,CAAmB;IAC5C,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,uCAAuC,CAAa;IAC5D,OAAO,CAAC,cAAc,CAA2B;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;gBAEV,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB;IAMxE,OAAO;IAId,+BAA+B;IAC/B,IAAW,aAAa,gBAEvB;IAGD,OAAO,CAAC,sBAAsB,CA4D5B;CACH"}
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  /** @packageDocumentation
6
6
  * @module UnifiedSelection
7
7
  */
@@ -44,7 +44,9 @@ export class SelectionManager {
44
44
  }
45
45
  /** @internal */
46
46
  // istanbul ignore next
47
- getToolSelectionSyncHandler(imodel) { return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler; }
47
+ getToolSelectionSyncHandler(imodel) {
48
+ return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;
49
+ }
48
50
  /**
49
51
  * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).
50
52
  */
@@ -77,8 +79,9 @@ export class SelectionManager {
77
79
  */
78
80
  suspendIModelToolSelectionSync(imodel) {
79
81
  const registration = this._imodelToolSelectionSyncHandlers.get(imodel);
80
- if (!registration)
82
+ if (!registration) {
81
83
  return { dispose: () => { } };
84
+ }
82
85
  const wasSuspended = registration.handler.isSuspended;
83
86
  registration.handler.isSuspended = true;
84
87
  return { dispose: () => (registration.handler.isSuspended = wasSuspended) };
@@ -113,8 +116,9 @@ export class SelectionManager {
113
116
  selectedItemsSet.clear();
114
117
  break;
115
118
  }
116
- if (selectedItemsSet.guid === guidBefore)
119
+ if (selectedItemsSet.guid === guidBefore) {
117
120
  return;
121
+ }
118
122
  container.clear(evt.level + 1);
119
123
  this.selectionChange.raiseEvent(evt, this);
120
124
  }
@@ -275,8 +279,9 @@ class SelectionContainer {
275
279
  getSelectionLevels() {
276
280
  const levels = new Array();
277
281
  for (const entry of this._selectedItemsSetMap.entries()) {
278
- if (!entry[1].isEmpty)
282
+ if (!entry[1].isEmpty) {
279
283
  levels.push(entry[0]);
284
+ }
280
285
  }
281
286
  return levels.sort();
282
287
  }
@@ -300,12 +305,14 @@ export class ToolSelectionSyncHandler {
300
305
  // eslint-disable-next-line @typescript-eslint/naming-convention
301
306
  this.onToolSelectionChanged = async (ev) => {
302
307
  // ignore selection change event if the handler is suspended
303
- if (this.isSuspended)
308
+ if (this.isSuspended) {
304
309
  return;
310
+ }
305
311
  // this component only cares about its own imodel
306
312
  const imodel = ev.set.iModel;
307
- if (imodel !== this._imodel)
313
+ if (imodel !== this._imodel) {
308
314
  return;
315
+ }
309
316
  // determine the level of selection changes
310
317
  // wip: may want to allow selecting at different levels?
311
318
  const selectionLevel = 0;
@@ -354,18 +361,23 @@ export class ToolSelectionSyncHandler {
354
361
  this._imodelToolSelectionListenerDisposeFunc();
355
362
  }
356
363
  /** note: used only it tests */
357
- get pendingAsyncs() { return this._asyncsTracker.pendingAsyncs; }
364
+ get pendingAsyncs() {
365
+ return this._asyncsTracker.pendingAsyncs;
366
+ }
358
367
  }
359
368
  const parseIds = (ids) => {
360
369
  let allPersistent = true;
361
370
  let allTransient = true;
362
371
  for (const id of Id64.iterable(ids)) {
363
- if (Id64.isTransient(id))
372
+ if (Id64.isTransient(id)) {
364
373
  allPersistent = false;
365
- else
374
+ }
375
+ else {
366
376
  allTransient = false;
367
- if (!allPersistent && !allTransient)
377
+ }
378
+ if (!allPersistent && !allTransient) {
368
379
  break;
380
+ }
369
381
  }
370
382
  // avoid making a copy if ids are only persistent or only transient
371
383
  if (allPersistent) {
@@ -379,16 +391,19 @@ const parseIds = (ids) => {
379
391
  const persistentElementIds = [];
380
392
  const transientElementIds = [];
381
393
  for (const id of Id64.iterable(ids)) {
382
- if (Id64.isTransient(id))
394
+ if (Id64.isTransient(id)) {
383
395
  transientElementIds.push(id);
384
- else
396
+ }
397
+ else {
385
398
  persistentElementIds.push(id);
399
+ }
386
400
  }
387
401
  return { persistent: persistentElementIds, transient: transientElementIds };
388
402
  };
389
403
  function addTransientKeys(transientIds, keys) {
390
- for (const id of Id64.iterable(transientIds))
404
+ for (const id of Id64.iterable(transientIds)) {
391
405
  keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });
406
+ }
392
407
  }
393
408
  /** @internal */
394
409
  class ScopedSelectionChanger {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAmC,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAqB,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EA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AI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrE,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 { Id64, Id64Arg, Id64Array, IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection, SelectionSetEvent, SelectionSetEventType } from \"@itwin/core-frontend\";\r\nimport { AsyncTasksTracker, Keys, KeySet, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\nimport { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\nimport { SelectionChangeEvent, SelectionChangeEventArgs, SelectionChangeType } from \"./SelectionChangeEvent\";\r\nimport { createSelectionScopeProps, SelectionScopesManager } from \"./SelectionScopesManager\";\r\n\r\n/**\r\n * Properties for creating [[SelectionManager]].\r\n * @public\r\n */\r\nexport interface SelectionManagerProps {\r\n /** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n scopes: SelectionScopesManager;\r\n}\r\n\r\n/**\r\n * The selection manager which stores the overall selection.\r\n * @public\r\n */\r\nexport class SelectionManager implements ISelectionProvider {\r\n private _selectionContainerMap = new Map<IModelConnection, SelectionContainer>();\r\n private _imodelToolSelectionSyncHandlers = new Map<IModelConnection, { requestorsCount: number, handler: ToolSelectionSyncHandler }>();\r\n private _hiliteSetProviders = new Map<IModelConnection, HiliteSetProvider>();\r\n\r\n /** An event which gets broadcasted on selection changes */\r\n public readonly selectionChange: SelectionChangeEvent;\r\n\r\n /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n public readonly scopes: SelectionScopesManager;\r\n\r\n /**\r\n * Creates an instance of SelectionManager.\r\n */\r\n constructor(props: SelectionManagerProps) {\r\n this.selectionChange = new SelectionChangeEvent();\r\n this.scopes = props.scopes;\r\n IModelConnection.onClose.addListener((imodel: IModelConnection) => {\r\n this.onConnectionClose(imodel);\r\n });\r\n }\r\n\r\n private onConnectionClose(imodel: IModelConnection): void {\r\n this.clearSelection(\"Connection Close Event\", imodel);\r\n this._selectionContainerMap.delete(imodel);\r\n this._hiliteSetProviders.delete(imodel);\r\n }\r\n\r\n private getContainer(imodel: IModelConnection): SelectionContainer {\r\n let selectionContainer = this._selectionContainerMap.get(imodel);\r\n if (!selectionContainer) {\r\n selectionContainer = new SelectionContainer();\r\n this._selectionContainerMap.set(imodel, selectionContainer);\r\n }\r\n return selectionContainer;\r\n }\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getToolSelectionSyncHandler(imodel: IModelConnection) { return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler; }\r\n\r\n /**\r\n * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).\r\n */\r\n public setSyncWithIModelToolSelection(imodel: IModelConnection, sync = true) {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (sync) {\r\n if (!registration || registration.requestorsCount === 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { requestorsCount: 1, handler: new ToolSelectionSyncHandler(imodel, this) });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount: registration.requestorsCount + 1 });\r\n }\r\n } else {\r\n if (registration && registration.requestorsCount > 0) {\r\n const requestorsCount = registration.requestorsCount - 1;\r\n if (requestorsCount > 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.delete(imodel);\r\n registration.handler.dispose();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Temporarily suspends tool selection synchronization until the returned `IDisposable`\r\n * is disposed.\r\n */\r\n public suspendIModelToolSelectionSync(imodel: IModelConnection): IDisposable {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (!registration)\r\n return { dispose: () => { } };\r\n\r\n const wasSuspended = registration.handler.isSuspended;\r\n registration.handler.isSuspended = true;\r\n return { dispose: () => (registration.handler.isSuspended = wasSuspended) };\r\n }\r\n\r\n /** Get the selection levels currently stored in this manager for the specified imodel */\r\n public getSelectionLevels(imodel: IModelConnection): number[] {\r\n return this.getContainer(imodel).getSelectionLevels();\r\n }\r\n\r\n /** Get the selection currently stored in this manager */\r\n public getSelection(imodel: IModelConnection, level: number = 0): Readonly<KeySet> {\r\n return this.getContainer(imodel).getSelection(level);\r\n }\r\n\r\n private handleEvent(evt: SelectionChangeEventArgs): void {\r\n const container = this.getContainer(evt.imodel);\r\n const selectedItemsSet = container.getSelection(evt.level);\r\n const guidBefore = selectedItemsSet.guid;\r\n switch (evt.changeType) {\r\n case SelectionChangeType.Add:\r\n selectedItemsSet.add(evt.keys);\r\n break;\r\n case SelectionChangeType.Remove:\r\n selectedItemsSet.delete(evt.keys);\r\n break;\r\n case SelectionChangeType.Replace:\r\n if (selectedItemsSet.size !== evt.keys.size || !selectedItemsSet.hasAll(evt.keys)) {\r\n // note: the above check is only needed to avoid changing\r\n // guid of the keyset if we're replacing keyset with the same keys\r\n selectedItemsSet.clear().add(evt.keys);\r\n }\r\n break;\r\n case SelectionChangeType.Clear:\r\n selectedItemsSet.clear();\r\n break;\r\n }\r\n\r\n if (selectedItemsSet.guid === guidBefore)\r\n return;\r\n\r\n container.clear(evt.level + 1);\r\n this.selectionChange.raiseEvent(evt, this);\r\n }\r\n\r\n /**\r\n * Add keys to the selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public addToSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Add,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to remove\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public removeFromSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Remove,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Replace current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public replaceSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Replace,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Clear current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public clearSelection(source: string, imodel: IModelConnection, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Clear,\r\n keys: new KeySet(),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Add keys to selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to add\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async addToSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.addToSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to remove\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async removeFromSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.removeFromSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Replace current selection with keys after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to replace with\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async replaceSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.replaceSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Get the current hilite set for the specified imodel\r\n * @public\r\n */\r\n public async getHiliteSet(imodel: IModelConnection): Promise<HiliteSet> {\r\n return this.getHiliteSetProvider(imodel).getHiliteSet(this.getSelection(imodel));\r\n }\r\n\r\n /**\r\n * Get the current hilite set iterator for the specified imodel.\r\n * @public\r\n */\r\n public getHiliteSetIterator(imodel: IModelConnection) {\r\n return this.getHiliteSetProvider(imodel).getHiliteSetIterator(this.getSelection(imodel));\r\n }\r\n\r\n private getHiliteSetProvider(imodel: IModelConnection) {\r\n let provider = this._hiliteSetProviders.get(imodel);\r\n if (!provider) {\r\n provider = HiliteSetProvider.create({ imodel });\r\n this._hiliteSetProviders.set(imodel, provider);\r\n }\r\n return provider;\r\n }\r\n}\r\n\r\n/** @internal */\r\nclass SelectionContainer {\r\n private readonly _selectedItemsSetMap: Map<number, KeySet>;\r\n\r\n constructor() {\r\n this._selectedItemsSetMap = new Map<number, KeySet>();\r\n }\r\n\r\n public getSelection(level: number): KeySet {\r\n let selectedItemsSet = this._selectedItemsSetMap.get(level);\r\n if (!selectedItemsSet) {\r\n selectedItemsSet = new KeySet();\r\n this._selectedItemsSetMap.set(level, selectedItemsSet);\r\n }\r\n return selectedItemsSet;\r\n }\r\n\r\n public getSelectionLevels(): number[] {\r\n const levels = new Array<number>();\r\n for (const entry of this._selectedItemsSetMap.entries()) {\r\n if (!entry[1].isEmpty)\r\n levels.push(entry[0]);\r\n }\r\n return levels.sort();\r\n }\r\n\r\n public clear(level: number) {\r\n const keys = this._selectedItemsSetMap.keys();\r\n for (const key of keys) {\r\n if (key >= level) {\r\n const selectedItemsSet = this._selectedItemsSetMap.get(key)!;\r\n selectedItemsSet.clear();\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\r\n\r\n/** @internal */\r\nexport class ToolSelectionSyncHandler implements IDisposable {\r\n\r\n private _selectionSourceName = \"Tool\";\r\n private _logicalSelection: SelectionManager;\r\n private _imodel: IModelConnection;\r\n private _imodelToolSelectionListenerDisposeFunc: () => void;\r\n private _asyncsTracker = new AsyncTasksTracker();\r\n public isSuspended?: boolean;\r\n\r\n public constructor(imodel: IModelConnection, logicalSelection: SelectionManager) {\r\n this._imodel = imodel;\r\n this._logicalSelection = logicalSelection;\r\n this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);\r\n }\r\n\r\n public dispose() {\r\n this._imodelToolSelectionListenerDisposeFunc();\r\n }\r\n\r\n /** note: used only it tests */\r\n public get pendingAsyncs() { return this._asyncsTracker.pendingAsyncs; }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onToolSelectionChanged = async (ev: SelectionSetEvent): Promise<void> => {\r\n // ignore selection change event if the handler is suspended\r\n if (this.isSuspended)\r\n return;\r\n\r\n // this component only cares about its own imodel\r\n const imodel = ev.set.iModel;\r\n if (imodel !== this._imodel)\r\n return;\r\n\r\n // determine the level of selection changes\r\n // wip: may want to allow selecting at different levels?\r\n const selectionLevel = 0;\r\n\r\n let ids: Id64Arg;\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n ids = ev.added;\r\n break;\r\n case SelectionSetEventType.Replace:\r\n ids = ev.set.elements;\r\n break;\r\n default:\r\n ids = ev.removed;\r\n break;\r\n }\r\n\r\n // we're always using scoped selection changer even if the scope is set to \"element\" - that\r\n // makes sure we're adding to selection keys with concrete classes and not \"BisCore:Element\", which\r\n // we can't because otherwise our keys compare fails (presentation components load data with\r\n // concrete classes)\r\n const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));\r\n\r\n // we know what to do immediately on `clear` events\r\n if (SelectionSetEventType.Clear === ev.type) {\r\n await changer.clear(selectionLevel);\r\n return;\r\n }\r\n\r\n const parsedIds = parseIds(ids);\r\n await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Replace:\r\n await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Remove:\r\n await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n }\r\n });\r\n };\r\n}\r\n\r\nconst parseIds = (ids: Id64Arg): { persistent: Id64Arg, transient: Id64Arg } => {\r\n let allPersistent = true;\r\n let allTransient = true;\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id))\r\n allPersistent = false;\r\n else\r\n allTransient = false;\r\n\r\n if (!allPersistent && !allTransient)\r\n break;\r\n }\r\n\r\n // avoid making a copy if ids are only persistent or only transient\r\n if (allPersistent) {\r\n return { persistent: ids, transient: [] };\r\n } else if (allTransient) {\r\n return { persistent: [], transient: ids };\r\n }\r\n\r\n // if `ids` contain mixed ids, we have to copy.. use Array instead of\r\n // a Set for performance\r\n const persistentElementIds: Id64Array = [];\r\n const transientElementIds: Id64Array = [];\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id))\r\n transientElementIds.push(id);\r\n else\r\n persistentElementIds.push(id);\r\n }\r\n\r\n return { persistent: persistentElementIds, transient: transientElementIds };\r\n};\r\n\r\nfunction addTransientKeys(transientIds: Id64Arg, keys: KeySet): void {\r\n for (const id of Id64.iterable(transientIds))\r\n keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });\r\n}\r\n\r\n/** @internal */\r\nclass ScopedSelectionChanger {\r\n public readonly name: string;\r\n public readonly imodel: IModelConnection;\r\n public readonly manager: SelectionManager;\r\n public readonly scope: SelectionScopeProps | SelectionScope | string;\r\n public constructor(name: string, imodel: IModelConnection, manager: SelectionManager, scope: SelectionScopeProps | SelectionScope | string) {\r\n this.name = name;\r\n this.imodel = imodel;\r\n this.manager = manager;\r\n this.scope = scope;\r\n }\r\n public async clear(level: number): Promise<void> {\r\n this.manager.clearSelection(this.name, this.imodel, level);\r\n }\r\n public async add(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.addToSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async remove(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.removeFromSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async replace(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.replaceSelection(this.name, this.imodel, keys, level);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAmC,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAqB,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAQ,MAAM,EAAuC,MAAM,4BAA4B,CAAC;AAClH,OAAO,EAAa,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,oBAAoB,E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AAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrE,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 { Id64, Id64Arg, Id64Array, IDisposable, using } from \"@itwin/core-bentley\";\nimport { IModelConnection, SelectionSetEvent, SelectionSetEventType } from \"@itwin/core-frontend\";\nimport { AsyncTasksTracker, Keys, KeySet, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\nimport { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\nimport { ISelectionProvider } from \"./ISelectionProvider\";\nimport { SelectionChangeEvent, SelectionChangeEventArgs, SelectionChangeType } from \"./SelectionChangeEvent\";\nimport { createSelectionScopeProps, SelectionScopesManager } from \"./SelectionScopesManager\";\n\n/**\n * Properties for creating [[SelectionManager]].\n * @public\n */\nexport interface SelectionManagerProps {\n /** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\n scopes: SelectionScopesManager;\n}\n\n/**\n * The selection manager which stores the overall selection.\n * @public\n */\nexport class SelectionManager implements ISelectionProvider {\n private _selectionContainerMap = new Map<IModelConnection, SelectionContainer>();\n private _imodelToolSelectionSyncHandlers = new Map<IModelConnection, { requestorsCount: number; handler: ToolSelectionSyncHandler }>();\n private _hiliteSetProviders = new Map<IModelConnection, HiliteSetProvider>();\n\n /** An event which gets broadcasted on selection changes */\n public readonly selectionChange: SelectionChangeEvent;\n\n /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\n public readonly scopes: SelectionScopesManager;\n\n /**\n * Creates an instance of SelectionManager.\n */\n constructor(props: SelectionManagerProps) {\n this.selectionChange = new SelectionChangeEvent();\n this.scopes = props.scopes;\n IModelConnection.onClose.addListener((imodel: IModelConnection) => {\n this.onConnectionClose(imodel);\n });\n }\n\n private onConnectionClose(imodel: IModelConnection): void {\n this.clearSelection(\"Connection Close Event\", imodel);\n this._selectionContainerMap.delete(imodel);\n this._hiliteSetProviders.delete(imodel);\n }\n\n private getContainer(imodel: IModelConnection): SelectionContainer {\n let selectionContainer = this._selectionContainerMap.get(imodel);\n if (!selectionContainer) {\n selectionContainer = new SelectionContainer();\n this._selectionContainerMap.set(imodel, selectionContainer);\n }\n return selectionContainer;\n }\n\n /** @internal */\n // istanbul ignore next\n public getToolSelectionSyncHandler(imodel: IModelConnection) {\n return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;\n }\n\n /**\n * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).\n */\n public setSyncWithIModelToolSelection(imodel: IModelConnection, sync = true) {\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\n if (sync) {\n if (!registration || registration.requestorsCount === 0) {\n this._imodelToolSelectionSyncHandlers.set(imodel, { requestorsCount: 1, handler: new ToolSelectionSyncHandler(imodel, this) });\n } else {\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount: registration.requestorsCount + 1 });\n }\n } else {\n if (registration && registration.requestorsCount > 0) {\n const requestorsCount = registration.requestorsCount - 1;\n if (requestorsCount > 0) {\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount });\n } else {\n this._imodelToolSelectionSyncHandlers.delete(imodel);\n registration.handler.dispose();\n }\n }\n }\n }\n\n /**\n * Temporarily suspends tool selection synchronization until the returned `IDisposable`\n * is disposed.\n */\n public suspendIModelToolSelectionSync(imodel: IModelConnection): IDisposable {\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\n if (!registration) {\n return { dispose: () => {} };\n }\n\n const wasSuspended = registration.handler.isSuspended;\n registration.handler.isSuspended = true;\n return { dispose: () => (registration.handler.isSuspended = wasSuspended) };\n }\n\n /** Get the selection levels currently stored in this manager for the specified imodel */\n public getSelectionLevels(imodel: IModelConnection): number[] {\n return this.getContainer(imodel).getSelectionLevels();\n }\n\n /** Get the selection currently stored in this manager */\n public getSelection(imodel: IModelConnection, level: number = 0): Readonly<KeySet> {\n return this.getContainer(imodel).getSelection(level);\n }\n\n private handleEvent(evt: SelectionChangeEventArgs): void {\n const container = this.getContainer(evt.imodel);\n const selectedItemsSet = container.getSelection(evt.level);\n const guidBefore = selectedItemsSet.guid;\n switch (evt.changeType) {\n case SelectionChangeType.Add:\n selectedItemsSet.add(evt.keys);\n break;\n case SelectionChangeType.Remove:\n selectedItemsSet.delete(evt.keys);\n break;\n case SelectionChangeType.Replace:\n if (selectedItemsSet.size !== evt.keys.size || !selectedItemsSet.hasAll(evt.keys)) {\n // note: the above check is only needed to avoid changing\n // guid of the keyset if we're replacing keyset with the same keys\n selectedItemsSet.clear().add(evt.keys);\n }\n break;\n case SelectionChangeType.Clear:\n selectedItemsSet.clear();\n break;\n }\n\n if (selectedItemsSet.guid === guidBefore) {\n return;\n }\n\n container.clear(evt.level + 1);\n this.selectionChange.raiseEvent(evt, this);\n }\n\n /**\n * Add keys to the selection\n * @param source Name of the selection source\n * @param imodel iModel associated with the selection\n * @param keys Keys to add\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\n */\n public addToSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\n const evt: SelectionChangeEventArgs = {\n source,\n level,\n imodel,\n changeType: SelectionChangeType.Add,\n keys: new KeySet(keys),\n timestamp: new Date(),\n rulesetId,\n };\n this.handleEvent(evt);\n }\n\n /**\n * Remove keys from current selection\n * @param source Name of the selection source\n * @param imodel iModel associated with the selection\n * @param keys Keys to remove\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\n */\n public removeFromSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\n const evt: SelectionChangeEventArgs = {\n source,\n level,\n imodel,\n changeType: SelectionChangeType.Remove,\n keys: new KeySet(keys),\n timestamp: new Date(),\n rulesetId,\n };\n this.handleEvent(evt);\n }\n\n /**\n * Replace current selection\n * @param source Name of the selection source\n * @param imodel iModel associated with the selection\n * @param keys Keys to add\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\n */\n public replaceSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\n const evt: SelectionChangeEventArgs = {\n source,\n level,\n imodel,\n changeType: SelectionChangeType.Replace,\n keys: new KeySet(keys),\n timestamp: new Date(),\n rulesetId,\n };\n this.handleEvent(evt);\n }\n\n /**\n * Clear current selection\n * @param source Name of the selection source\n * @param imodel iModel associated with the selection\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\n */\n public clearSelection(source: string, imodel: IModelConnection, level: number = 0, rulesetId?: string): void {\n const evt: SelectionChangeEventArgs = {\n source,\n level,\n imodel,\n changeType: SelectionChangeType.Clear,\n keys: new KeySet(),\n timestamp: new Date(),\n rulesetId,\n };\n this.handleEvent(evt);\n }\n\n /**\n * Add keys to selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\n * @param source Name of the selection source\n * @param imodel iModel associated with the selection\n * @param ids Element IDs to add\n * @param scope Selection scope to apply\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\n */\n public async addToSelectionWithScope(\n source: string,\n imodel: IModelConnection,\n ids: Id64Arg,\n scope: SelectionScopeProps | SelectionScope | string,\n level: number = 0,\n rulesetId?: string,\n ): Promise<void> {\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\n this.addToSelection(source, imodel, scopedKeys, level, rulesetId);\n }\n\n /**\n * Remove keys from current selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\n * @param source Name of the selection source\n * @param imodel iModel associated with the selection\n * @param ids Element IDs to remove\n * @param scope Selection scope to apply\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\n */\n public async removeFromSelectionWithScope(\n source: string,\n imodel: IModelConnection,\n ids: Id64Arg,\n scope: SelectionScopeProps | SelectionScope | string,\n level: number = 0,\n rulesetId?: string,\n ): Promise<void> {\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\n this.removeFromSelection(source, imodel, scopedKeys, level, rulesetId);\n }\n\n /**\n * Replace current selection with keys after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\n * @param source Name of the selection source\n * @param imodel iModel associated with the selection\n * @param ids Element IDs to replace with\n * @param scope Selection scope to apply\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\n */\n public async replaceSelectionWithScope(\n source: string,\n imodel: IModelConnection,\n ids: Id64Arg,\n scope: SelectionScopeProps | SelectionScope | string,\n level: number = 0,\n rulesetId?: string,\n ): Promise<void> {\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\n this.replaceSelection(source, imodel, scopedKeys, level, rulesetId);\n }\n\n /**\n * Get the current hilite set for the specified imodel\n * @public\n */\n public async getHiliteSet(imodel: IModelConnection): Promise<HiliteSet> {\n return this.getHiliteSetProvider(imodel).getHiliteSet(this.getSelection(imodel));\n }\n\n /**\n * Get the current hilite set iterator for the specified imodel.\n * @public\n */\n public getHiliteSetIterator(imodel: IModelConnection) {\n return this.getHiliteSetProvider(imodel).getHiliteSetIterator(this.getSelection(imodel));\n }\n\n private getHiliteSetProvider(imodel: IModelConnection) {\n let provider = this._hiliteSetProviders.get(imodel);\n if (!provider) {\n provider = HiliteSetProvider.create({ imodel });\n this._hiliteSetProviders.set(imodel, provider);\n }\n return provider;\n }\n}\n\n/** @internal */\nclass SelectionContainer {\n private readonly _selectedItemsSetMap: Map<number, KeySet>;\n\n constructor() {\n this._selectedItemsSetMap = new Map<number, KeySet>();\n }\n\n public getSelection(level: number): KeySet {\n let selectedItemsSet = this._selectedItemsSetMap.get(level);\n if (!selectedItemsSet) {\n selectedItemsSet = new KeySet();\n this._selectedItemsSetMap.set(level, selectedItemsSet);\n }\n return selectedItemsSet;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectedItemsSetMap.entries()) {\n if (!entry[1].isEmpty) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const keys = this._selectedItemsSetMap.keys();\n for (const key of keys) {\n if (key >= level) {\n const selectedItemsSet = this._selectedItemsSetMap.get(key)!;\n selectedItemsSet.clear();\n }\n }\n }\n}\n\n/** @internal */\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\n\n/** @internal */\nexport class ToolSelectionSyncHandler implements IDisposable {\n private _selectionSourceName = \"Tool\";\n private _logicalSelection: SelectionManager;\n private _imodel: IModelConnection;\n private _imodelToolSelectionListenerDisposeFunc: () => void;\n private _asyncsTracker = new AsyncTasksTracker();\n public isSuspended?: boolean;\n\n public constructor(imodel: IModelConnection, logicalSelection: SelectionManager) {\n this._imodel = imodel;\n this._logicalSelection = logicalSelection;\n this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);\n }\n\n public dispose() {\n this._imodelToolSelectionListenerDisposeFunc();\n }\n\n /** note: used only it tests */\n public get pendingAsyncs() {\n return this._asyncsTracker.pendingAsyncs;\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onToolSelectionChanged = async (ev: SelectionSetEvent): Promise<void> => {\n // ignore selection change event if the handler is suspended\n if (this.isSuspended) {\n return;\n }\n\n // this component only cares about its own imodel\n const imodel = ev.set.iModel;\n if (imodel !== this._imodel) {\n return;\n }\n\n // determine the level of selection changes\n // wip: may want to allow selecting at different levels?\n const selectionLevel = 0;\n\n let ids: Id64Arg;\n switch (ev.type) {\n case SelectionSetEventType.Add:\n ids = ev.added;\n break;\n case SelectionSetEventType.Replace:\n ids = ev.set.elements;\n break;\n default:\n ids = ev.removed;\n break;\n }\n\n // we're always using scoped selection changer even if the scope is set to \"element\" - that\n // makes sure we're adding to selection keys with concrete classes and not \"BisCore:Element\", which\n // we can't because otherwise our keys compare fails (presentation components load data with\n // concrete classes)\n const changer = new ScopedSelectionChanger(\n this._selectionSourceName,\n this._imodel,\n this._logicalSelection,\n createSelectionScopeProps(this._logicalSelection.scopes.activeScope),\n );\n\n // we know what to do immediately on `clear` events\n if (SelectionSetEventType.Clear === ev.type) {\n await changer.clear(selectionLevel);\n return;\n }\n\n const parsedIds = parseIds(ids);\n await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {\n switch (ev.type) {\n case SelectionSetEventType.Add:\n await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);\n break;\n case SelectionSetEventType.Replace:\n await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);\n break;\n case SelectionSetEventType.Remove:\n await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);\n break;\n }\n });\n };\n}\n\nconst parseIds = (ids: Id64Arg): { persistent: Id64Arg; transient: Id64Arg } => {\n let allPersistent = true;\n let allTransient = true;\n for (const id of Id64.iterable(ids)) {\n if (Id64.isTransient(id)) {\n allPersistent = false;\n } else {\n allTransient = false;\n }\n\n if (!allPersistent && !allTransient) {\n break;\n }\n }\n\n // avoid making a copy if ids are only persistent or only transient\n if (allPersistent) {\n return { persistent: ids, transient: [] };\n } else if (allTransient) {\n return { persistent: [], transient: ids };\n }\n\n // if `ids` contain mixed ids, we have to copy.. use Array instead of\n // a Set for performance\n const persistentElementIds: Id64Array = [];\n const transientElementIds: Id64Array = [];\n for (const id of Id64.iterable(ids)) {\n if (Id64.isTransient(id)) {\n transientElementIds.push(id);\n } else {\n persistentElementIds.push(id);\n }\n }\n\n return { persistent: persistentElementIds, transient: transientElementIds };\n};\n\nfunction addTransientKeys(transientIds: Id64Arg, keys: KeySet): void {\n for (const id of Id64.iterable(transientIds)) {\n keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });\n }\n}\n\n/** @internal */\nclass ScopedSelectionChanger {\n public readonly name: string;\n public readonly imodel: IModelConnection;\n public readonly manager: SelectionManager;\n public readonly scope: SelectionScopeProps | SelectionScope | string;\n public constructor(name: string, imodel: IModelConnection, manager: SelectionManager, scope: SelectionScopeProps | SelectionScope | string) {\n this.name = name;\n this.imodel = imodel;\n this.manager = manager;\n this.scope = scope;\n }\n public async clear(level: number): Promise<void> {\n this.manager.clearSelection(this.name, this.imodel, level);\n }\n public async add(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\n addTransientKeys(transientIds, keys);\n this.manager.addToSelection(this.name, this.imodel, keys, level);\n }\n public async remove(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\n addTransientKeys(transientIds, keys);\n this.manager.removeFromSelection(this.name, this.imodel, keys, level);\n }\n public async replace(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\n addTransientKeys(transientIds, keys);\n this.manager.replaceSelection(this.name, this.imodel, keys, level);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionScopesManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionScopesManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,O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,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAE7E"}
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  /** @packageDocumentation
6
6
  * @module UnifiedSelection
7
7
  */
@@ -15,21 +15,28 @@ import { DEFAULT_KEYS_BATCH_SIZE, KeySet } from "@itwin/presentation-common";
15
15
  export class SelectionScopesManager {
16
16
  constructor(props) {
17
17
  this._rpcRequestsHandler = props.rpcRequestsHandler;
18
- this._getLocale = props.localeProvider ? props.localeProvider : (() => undefined);
18
+ this._getLocale = props.localeProvider ? props.localeProvider : () => undefined;
19
19
  }
20
20
  /** Get active locale */
21
- get activeLocale() { return this._getLocale(); }
21
+ get activeLocale() {
22
+ return this._getLocale();
23
+ }
22
24
  /** The active selection scope or its id */
23
- get activeScope() { return this._activeScope; }
24
- set activeScope(scope) { this._activeScope = scope; }
25
+ get activeScope() {
26
+ return this._activeScope;
27
+ }
28
+ set activeScope(scope) {
29
+ this._activeScope = scope;
30
+ }
25
31
  /**
26
32
  * Get available selection scopes.
27
33
  * @param imodel The iModel to get selection scopes for
28
34
  * @param locale Optional locale to use when localizing scopes' label and description
29
35
  */
30
36
  async getSelectionScopes(imodel, locale) {
31
- if (!locale)
37
+ if (!locale) {
32
38
  locale = this._getLocale();
39
+ }
33
40
  return this._rpcRequestsHandler.getSelectionScopes({ imodel: imodel.getRpcProps(), locale });
34
41
  }
35
42
  /**
@@ -40,10 +47,12 @@ export class SelectionScopesManager {
40
47
  async computeSelection(imodel, ids, scope) {
41
48
  const scopeProps = createSelectionScopeProps(scope);
42
49
  // convert ids input to array
43
- if (typeof ids === "string")
50
+ if (typeof ids === "string") {
44
51
  ids = [ids];
45
- else if (ids instanceof Set)
52
+ }
53
+ else if (ids instanceof Set) {
46
54
  ids = [...ids];
55
+ }
47
56
  // compute selection in batches to avoid HTTP 413
48
57
  const keys = new KeySet();
49
58
  const batchSize = DEFAULT_KEYS_BATCH_SIZE;
@@ -51,8 +60,8 @@ export class SelectionScopesManager {
51
60
  const batchKeyPromises = [];
52
61
  for (let batchIndex = 0; batchIndex < batchesCount; ++batchIndex) {
53
62
  const batchStart = batchSize * batchIndex;
54
- const batchEnd = (batchStart + batchSize > ids.length) ? ids.length : (batchStart + batchSize);
55
- const batchIds = (0 === batchIndex && ids.length <= batchEnd) ? ids : ids.slice(batchStart, batchEnd);
63
+ const batchEnd = batchStart + batchSize > ids.length ? ids.length : batchStart + batchSize;
64
+ const batchIds = 0 === batchIndex && ids.length <= batchEnd ? ids : ids.slice(batchStart, batchEnd);
56
65
  batchKeyPromises.push(this._rpcRequestsHandler.computeSelection({ imodel: imodel.getRpcProps(), elementIds: batchIds, scope: scopeProps }));
57
66
  }
58
67
  const batchKeys = (await Promise.all(batchKeyPromises)).map((json) => KeySet.fromJSON(json));
@@ -67,10 +76,12 @@ export class SelectionScopesManager {
67
76
  * @public
68
77
  */
69
78
  export function createSelectionScopeProps(scope) {
70
- if (!scope)
79
+ if (!scope) {
71
80
  return { id: "element" };
72
- if (typeof scope === "string")
81
+ }
82
+ if (typeof scope === "string") {
73
83
  return { id: scope };
84
+ }
74
85
  return scope;
75
86
  }
76
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionScopesManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionScopesManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAA2D,MAAM,4BAA4B,CAAC;AActI;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAMjC,YAAmB,KAAkC;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AAQ;QAC3B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IACvB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,uBAAuB;AACvB,MAAM,UAAU,UAAU,CAAC,KAA0C;IACnE,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC","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 { Id64Arg } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { DEFAULT_KEYS_BATCH_SIZE, KeySet, RpcRequestsHandler, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Properties for creating [[SelectionScopesManager]].\r\n * @public\r\n */\r\nexport interface SelectionScopesManagerProps {\r\n /** RPC handler to use for requesting selection scopes */\r\n rpcRequestsHandler: RpcRequestsHandler;\r\n\r\n /** Provider of active locale to use for localizing scopes */\r\n localeProvider?: () => string | undefined;\r\n}\r\n\r\n/**\r\n * A manager that knows available [selection scopes]($docs/presentation/unified-selection/index#selection-scopes)\r\n * and can compute logical selection based on element IDs and selection scope.\r\n *\r\n * @public\r\n */\r\nexport class SelectionScopesManager {\r\n\r\n private _rpcRequestsHandler: RpcRequestsHandler;\r\n private _getLocale: () => string | undefined;\r\n private _activeScope: SelectionScopeProps | SelectionScope | string | undefined;\r\n\r\n public constructor(props: SelectionScopesManagerProps) {\r\n this._rpcRequestsHandler = props.rpcRequestsHandler;\r\n this._getLocale = props.localeProvider ? props.localeProvider : (() => undefined);\r\n }\r\n\r\n /** Get active locale */\r\n public get activeLocale() { return this._getLocale(); }\r\n\r\n /** The active selection scope or its id */\r\n public get activeScope() { return this._activeScope; }\r\n public set activeScope(scope: SelectionScopeProps | SelectionScope | string | undefined) { this._activeScope = scope; }\r\n\r\n /**\r\n * Get available selection scopes.\r\n * @param imodel The iModel to get selection scopes for\r\n * @param locale Optional locale to use when localizing scopes' label and description\r\n */\r\n public async getSelectionScopes(imodel: IModelConnection, locale?: string): Promise<SelectionScope[]> {\r\n if (!locale)\r\n locale = this._getLocale();\r\n return this._rpcRequestsHandler.getSelectionScopes({ imodel: imodel.getRpcProps(), locale });\r\n }\r\n\r\n /**\r\n * Computes keys that need to be added to logical selection based on provided selection scope.\r\n * @param ids Element IDs to compute selection for\r\n * @param scope Selection scope to apply\r\n */\r\n public async computeSelection(imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string): Promise<KeySet> {\r\n const scopeProps = createSelectionScopeProps(scope);\r\n\r\n // convert ids input to array\r\n if (typeof ids === \"string\")\r\n ids = [ids];\r\n else if (ids instanceof Set)\r\n ids = [...ids];\r\n\r\n // compute selection in batches to avoid HTTP 413\r\n const keys = new KeySet();\r\n const batchSize = DEFAULT_KEYS_BATCH_SIZE;\r\n const batchesCount = Math.ceil(ids.length / batchSize);\r\n const batchKeyPromises = [];\r\n for (let batchIndex = 0; batchIndex < batchesCount; ++batchIndex) {\r\n const batchStart = batchSize * batchIndex;\r\n const batchEnd = (batchStart + batchSize > ids.length) ? ids.length : (batchStart + batchSize);\r\n const batchIds = (0 === batchIndex && ids.length <= batchEnd) ? ids : ids.slice(batchStart, batchEnd);\r\n batchKeyPromises.push(this._rpcRequestsHandler.computeSelection({ imodel: imodel.getRpcProps(), elementIds: batchIds, scope: scopeProps }));\r\n }\r\n const batchKeys = (await Promise.all(batchKeyPromises)).map((json) => KeySet.fromJSON(json));\r\n batchKeys.forEach((bk) => keys.add(bk));\r\n return keys;\r\n }\r\n}\r\n\r\n/**\r\n * Normalizes given scope options and returns [[SelectionScopeProps]] that can be used for\r\n * calculating selection with scope.\r\n *\r\n * @public\r\n */\r\nexport function createSelectionScopeProps(scope: SelectionScopeProps | SelectionScope | string | undefined): SelectionScopeProps {\r\n if (!scope)\r\n return { id: \"element\" };\r\n if (typeof scope === \"string\")\r\n return { id: scope };\r\n return scope;\r\n}\r\n\r\n/**\r\n * Determines the scope id\r\n * @param scope Selection scope\r\n * @public\r\n * @deprecated in 3.x. This is an internal utility that should've never become public.\r\n */\r\n// istanbul ignore next\r\nexport function getScopeId(scope: SelectionScope | string | undefined): string {\r\n return createSelectionScopeProps(scope).id;\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionScopesManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionScopesManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAA2D,MAAM,4BAA4B,CAAC;AActI;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAKjC,YAAmB,KAAkC;QACnD,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,kBAAkB,CAAC;QACpD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;IAClF,CAAC;IAED,wBAAwB;IACxB,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAED,2CAA2C;IAC3C,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IACD,IAAW,WAAW,CAAC,KAAgE;QACrF,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,kBAAkB,CAAC,MAAwB,EAAE,MAAe;QACvE,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;SAC5B;QACD,OAAO,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,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,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;SAC7I;QACD,MAAM,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAC7F,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAgE;IACxG,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;KAC1B;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;QAC7B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;KACtB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,uBAAuB;AACvB,MAAM,UAAU,UAAU,CAAC,KAA0C;IACnE,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC","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 { Id64Arg } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { DEFAULT_KEYS_BATCH_SIZE, KeySet, RpcRequestsHandler, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\n\n/**\n * Properties for creating [[SelectionScopesManager]].\n * @public\n */\nexport interface SelectionScopesManagerProps {\n /** RPC handler to use for requesting selection scopes */\n rpcRequestsHandler: RpcRequestsHandler;\n\n /** Provider of active locale to use for localizing scopes */\n localeProvider?: () => string | undefined;\n}\n\n/**\n * A manager that knows available [selection scopes]($docs/presentation/unified-selection/index#selection-scopes)\n * and can compute logical selection based on element IDs and selection scope.\n *\n * @public\n */\nexport class SelectionScopesManager {\n private _rpcRequestsHandler: RpcRequestsHandler;\n private _getLocale: () => string | undefined;\n private _activeScope: SelectionScopeProps | SelectionScope | string | undefined;\n\n public constructor(props: SelectionScopesManagerProps) {\n this._rpcRequestsHandler = props.rpcRequestsHandler;\n this._getLocale = props.localeProvider ? props.localeProvider : () => undefined;\n }\n\n /** Get active locale */\n public get activeLocale() {\n return this._getLocale();\n }\n\n /** The active selection scope or its id */\n public get activeScope() {\n return this._activeScope;\n }\n public set activeScope(scope: SelectionScopeProps | SelectionScope | string | undefined) {\n this._activeScope = scope;\n }\n\n /**\n * Get available selection scopes.\n * @param imodel The iModel to get selection scopes for\n * @param locale Optional locale to use when localizing scopes' label and description\n */\n public async getSelectionScopes(imodel: IModelConnection, locale?: string): Promise<SelectionScope[]> {\n if (!locale) {\n locale = this._getLocale();\n }\n return this._rpcRequestsHandler.getSelectionScopes({ imodel: imodel.getRpcProps(), locale });\n }\n\n /**\n * Computes keys that need to be added to logical selection based on provided selection scope.\n * @param ids Element IDs to compute selection for\n * @param scope Selection scope to apply\n */\n public async computeSelection(imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string): Promise<KeySet> {\n const scopeProps = createSelectionScopeProps(scope);\n\n // convert ids input to array\n if (typeof ids === \"string\") {\n ids = [ids];\n } else if (ids instanceof Set) {\n ids = [...ids];\n }\n\n // compute selection in batches to avoid HTTP 413\n const keys = new KeySet();\n const batchSize = DEFAULT_KEYS_BATCH_SIZE;\n const batchesCount = Math.ceil(ids.length / batchSize);\n const batchKeyPromises = [];\n for (let batchIndex = 0; batchIndex < batchesCount; ++batchIndex) {\n const batchStart = batchSize * batchIndex;\n const batchEnd = batchStart + batchSize > ids.length ? ids.length : batchStart + batchSize;\n const batchIds = 0 === batchIndex && ids.length <= batchEnd ? ids : ids.slice(batchStart, batchEnd);\n batchKeyPromises.push(this._rpcRequestsHandler.computeSelection({ imodel: imodel.getRpcProps(), elementIds: batchIds, scope: scopeProps }));\n }\n const batchKeys = (await Promise.all(batchKeyPromises)).map((json) => KeySet.fromJSON(json));\n batchKeys.forEach((bk) => keys.add(bk));\n return keys;\n }\n}\n\n/**\n * Normalizes given scope options and returns [[SelectionScopeProps]] that can be used for\n * calculating selection with scope.\n *\n * @public\n */\nexport function createSelectionScopeProps(scope: SelectionScopeProps | SelectionScope | string | undefined): SelectionScopeProps {\n if (!scope) {\n return { id: \"element\" };\n }\n if (typeof scope === \"string\") {\n return { id: scope };\n }\n return scope;\n}\n\n/**\n * Determines the scope id\n * @param scope Selection scope\n * @public\n * @deprecated in 3.x. This is an internal utility that should've never become public.\n */\n// istanbul ignore next\nexport function getScopeId(scope: SelectionScope | string | undefined): string {\n return createSelectionScopeProps(scope).id;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
5
  /**
6
6
  * @module Core
7
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"presentation-frontend.js","sourceRoot":"","sources":["../../src/presentation-frontend.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,iDAAiD,CAAC;AAChE,cAAc,uEAAuE,CAAC;AACtF,cAAc,uEAAuE,CAAC;AACtF,cAAc,qCAAqC,CAAC;AAEpD;;;;;GAKG;AACH,cAAc,gDAAgD,CAAC;AAE/D;;;;;GAKG;AACH,cAAc,wDAAwD,CAAC;AACvE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,qDAAqD,CAAC;AACpE,cAAc,mDAAmD,CAAC","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/**\r\n * @module Core\r\n *\r\n * @docs-group-description Core\r\n * Common types used for retrieving presentation data from iModels.\r\n */\r\nexport * from \"./presentation-frontend/Presentation\";\r\nexport * from \"./presentation-frontend/PresentationManager\";\r\nexport * from \"./presentation-frontend/RulesetManager\";\r\nexport * from \"./presentation-frontend/RulesetVariablesManager\";\r\nexport * from \"./presentation-frontend/favorite-properties/FavoritePropertiesManager\";\r\nexport * from \"./presentation-frontend/favorite-properties/FavoritePropertiesStorage\";\r\nexport * from \"./presentation-frontend/Diagnostics\";\r\n\r\n/**\r\n * @module Logging\r\n *\r\n * @docs-group-description Logging\r\n * Types related to logging in this package.\r\n */\r\nexport * from \"./presentation-frontend/FrontendLoggerCategory\";\r\n\r\n/**\r\n * @module UnifiedSelection\r\n *\r\n * @docs-group-description UnifiedSelection\r\n * Types related to [unified selection]($docs/presentation/unified-selection/index.md).\r\n */\r\nexport * from \"./presentation-frontend/selection/SelectionChangeEvent\";\r\nexport * from \"./presentation-frontend/selection/ISelectionProvider\";\r\nexport * from \"./presentation-frontend/selection/SelectionManager\";\r\nexport * from \"./presentation-frontend/selection/SelectionScopesManager\";\r\nexport * from \"./presentation-frontend/selection/SelectionHandler\";\r\nexport * from \"./presentation-frontend/selection/HiliteSetProvider\";\r\nexport * from \"./presentation-frontend/selection/SelectionHelper\";\r\n"]}
1
+ {"version":3,"file":"presentation-frontend.js","sourceRoot":"","sources":["../../src/presentation-frontend.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;;;;GAKG;AACH,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,iDAAiD,CAAC;AAChE,cAAc,uEAAuE,CAAC;AACtF,cAAc,uEAAuE,CAAC;AACtF,cAAc,qCAAqC,CAAC;AAEpD;;;;;GAKG;AACH,cAAc,gDAAgD,CAAC;AAE/D;;;;;GAKG;AACH,cAAc,wDAAwD,CAAC;AACvE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,qDAAqD,CAAC;AACpE,cAAc,mDAAmD,CAAC","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/**\n * @module Core\n *\n * @docs-group-description Core\n * Common types used for retrieving presentation data from iModels.\n */\nexport * from \"./presentation-frontend/Presentation\";\nexport * from \"./presentation-frontend/PresentationManager\";\nexport * from \"./presentation-frontend/RulesetManager\";\nexport * from \"./presentation-frontend/RulesetVariablesManager\";\nexport * from \"./presentation-frontend/favorite-properties/FavoritePropertiesManager\";\nexport * from \"./presentation-frontend/favorite-properties/FavoritePropertiesStorage\";\nexport * from \"./presentation-frontend/Diagnostics\";\n\n/**\n * @module Logging\n *\n * @docs-group-description Logging\n * Types related to logging in this package.\n */\nexport * from \"./presentation-frontend/FrontendLoggerCategory\";\n\n/**\n * @module UnifiedSelection\n *\n * @docs-group-description UnifiedSelection\n * Types related to [unified selection]($docs/presentation/unified-selection/index.md).\n */\nexport * from \"./presentation-frontend/selection/SelectionChangeEvent\";\nexport * from \"./presentation-frontend/selection/ISelectionProvider\";\nexport * from \"./presentation-frontend/selection/SelectionManager\";\nexport * from \"./presentation-frontend/selection/SelectionScopesManager\";\nexport * from \"./presentation-frontend/selection/SelectionHandler\";\nexport * from \"./presentation-frontend/selection/HiliteSetProvider\";\nexport * from \"./presentation-frontend/selection/SelectionHelper\";\n"]}