@itwin/unified-selection 0.2.0 → 0.3.0

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 (94) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/README.md +34 -14
  3. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts +3 -7
  4. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -1
  5. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +14 -17
  6. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +1 -1
  7. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  8. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  9. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +205 -0
  10. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  11. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts +2 -4
  12. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts.map +1 -1
  13. package/lib/cjs/unified-selection/HiliteSetProvider.js +156 -110
  14. package/lib/cjs/unified-selection/HiliteSetProvider.js.map +1 -1
  15. package/lib/cjs/unified-selection/Selectable.d.ts +0 -3
  16. package/lib/cjs/unified-selection/Selectable.d.ts.map +1 -1
  17. package/lib/cjs/unified-selection/Selectable.js +2 -2
  18. package/lib/cjs/unified-selection/Selectable.js.map +1 -1
  19. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts +5 -3
  20. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  21. package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +1 -1
  22. package/lib/cjs/unified-selection/SelectionScope.d.ts +2 -2
  23. package/lib/cjs/unified-selection/SelectionScope.d.ts.map +1 -1
  24. package/lib/cjs/unified-selection/SelectionScope.js +87 -54
  25. package/lib/cjs/unified-selection/SelectionScope.js.map +1 -1
  26. package/lib/cjs/unified-selection/SelectionStorage.d.ts +20 -28
  27. package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
  28. package/lib/cjs/unified-selection/SelectionStorage.js +21 -18
  29. package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
  30. package/lib/cjs/unified-selection/Utils.d.ts +7 -0
  31. package/lib/cjs/unified-selection/Utils.d.ts.map +1 -0
  32. package/lib/cjs/unified-selection/{queries/ECSqlCore.js → Utils.js} +2 -1
  33. package/lib/cjs/unified-selection/Utils.js.map +1 -0
  34. package/lib/cjs/unified-selection/types/IModel.d.ts +84 -0
  35. package/lib/cjs/unified-selection/types/IModel.d.ts.map +1 -0
  36. package/lib/cjs/unified-selection/types/IModel.js +24 -0
  37. package/lib/cjs/unified-selection/types/IModel.js.map +1 -0
  38. package/lib/cjs/unified-selection.d.ts +1 -6
  39. package/lib/cjs/unified-selection.d.ts.map +1 -1
  40. package/lib/cjs/unified-selection.js +3 -7
  41. package/lib/cjs/unified-selection.js.map +1 -1
  42. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts +3 -7
  43. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -1
  44. package/lib/esm/unified-selection/CachingHiliteSetProvider.js +14 -17
  45. package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +1 -1
  46. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  47. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  48. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +200 -0
  49. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  50. package/lib/esm/unified-selection/HiliteSetProvider.d.ts +2 -4
  51. package/lib/esm/unified-selection/HiliteSetProvider.d.ts.map +1 -1
  52. package/lib/esm/unified-selection/HiliteSetProvider.js +155 -109
  53. package/lib/esm/unified-selection/HiliteSetProvider.js.map +1 -1
  54. package/lib/esm/unified-selection/Selectable.d.ts +0 -3
  55. package/lib/esm/unified-selection/Selectable.d.ts.map +1 -1
  56. package/lib/esm/unified-selection/Selectable.js.map +1 -1
  57. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +5 -3
  58. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  59. package/lib/esm/unified-selection/SelectionChangeEvent.js.map +1 -1
  60. package/lib/esm/unified-selection/SelectionScope.d.ts +2 -2
  61. package/lib/esm/unified-selection/SelectionScope.d.ts.map +1 -1
  62. package/lib/esm/unified-selection/SelectionScope.js +84 -51
  63. package/lib/esm/unified-selection/SelectionScope.js.map +1 -1
  64. package/lib/esm/unified-selection/SelectionStorage.d.ts +20 -28
  65. package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
  66. package/lib/esm/unified-selection/SelectionStorage.js +21 -18
  67. package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
  68. package/lib/esm/unified-selection/Utils.d.ts +7 -0
  69. package/lib/esm/unified-selection/Utils.d.ts.map +1 -0
  70. package/lib/esm/unified-selection/{queries/ECSqlCore.js → Utils.js} +2 -1
  71. package/lib/esm/unified-selection/Utils.js.map +1 -0
  72. package/lib/esm/unified-selection/types/IModel.d.ts +84 -0
  73. package/lib/esm/unified-selection/types/IModel.d.ts.map +1 -0
  74. package/lib/esm/unified-selection/types/IModel.js +21 -0
  75. package/lib/esm/unified-selection/types/IModel.js.map +1 -0
  76. package/lib/esm/unified-selection.d.ts +1 -6
  77. package/lib/esm/unified-selection.d.ts.map +1 -1
  78. package/lib/esm/unified-selection.js +1 -6
  79. package/lib/esm/unified-selection.js.map +1 -1
  80. package/package.json +23 -16
  81. package/lib/cjs/unified-selection/queries/ECMetadata.d.ts +0 -44
  82. package/lib/cjs/unified-selection/queries/ECMetadata.d.ts.map +0 -1
  83. package/lib/cjs/unified-selection/queries/ECMetadata.js +0 -17
  84. package/lib/cjs/unified-selection/queries/ECMetadata.js.map +0 -1
  85. package/lib/cjs/unified-selection/queries/ECSqlCore.d.ts +0 -69
  86. package/lib/cjs/unified-selection/queries/ECSqlCore.d.ts.map +0 -1
  87. package/lib/cjs/unified-selection/queries/ECSqlCore.js.map +0 -1
  88. package/lib/esm/unified-selection/queries/ECMetadata.d.ts +0 -44
  89. package/lib/esm/unified-selection/queries/ECMetadata.d.ts.map +0 -1
  90. package/lib/esm/unified-selection/queries/ECMetadata.js +0 -13
  91. package/lib/esm/unified-selection/queries/ECMetadata.js.map +0 -1
  92. package/lib/esm/unified-selection/queries/ECSqlCore.d.ts +0 -69
  93. package/lib/esm/unified-selection/queries/ECSqlCore.d.ts.map +0 -1
  94. package/lib/esm/unified-selection/queries/ECSqlCore.js.map +0 -1
@@ -5,9 +5,6 @@
5
5
  *--------------------------------------------------------------------------------------------*/
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = exports.createStorage = void 0;
8
- /** @packageDocumentation
9
- * @module UnifiedSelection
10
- */
11
8
  const Selectable_1 = require("./Selectable");
12
9
  const SelectionChangeEvent_1 = require("./SelectionChangeEvent");
13
10
  /**
@@ -16,8 +13,8 @@ const SelectionChangeEvent_1 = require("./SelectionChangeEvent");
16
13
  * **Note:** `clearSelection` should be called upon iModel close to free-up memory:
17
14
  * ```ts
18
15
  * import { IModelConnection } from "@itwin/core-frontend";
19
- * IModelConnection.onClose.addListener((iModel) => {
20
- * storage.clearStorage(iModel.key);
16
+ * IModelConnection.onClose.addListener((imodel) => {
17
+ * storage.clearStorage(imodel.key);
21
18
  * });
22
19
  * ```
23
20
  *
@@ -35,12 +32,11 @@ class SelectionStorageImpl {
35
32
  constructor() {
36
33
  this.selectionChangeEvent = new SelectionChangeEvent_1.SelectionChangeEventImpl();
37
34
  }
38
- getSelectionLevels({ iModelKey }) {
39
- return this.getContainer(iModelKey).getSelectionLevels();
35
+ getSelectionLevels(props) {
36
+ return this.getContainer(getIModelKey(props)).getSelectionLevels();
40
37
  }
41
38
  getSelection(props) {
42
- const { iModelKey, level } = props;
43
- return this.getContainer(iModelKey).getSelection(level ?? 0);
39
+ return this.getContainer(getIModelKey(props)).getSelection(props.level ?? 0);
44
40
  }
45
41
  addToSelection(props) {
46
42
  this.handleChange({ ...props, changeType: "add" });
@@ -54,21 +50,23 @@ class SelectionStorageImpl {
54
50
  clearSelection(props) {
55
51
  this.handleChange({ ...props, changeType: "clear", selectables: [] });
56
52
  }
57
- clearStorage({ iModelKey }) {
58
- this.clearSelection({ source: exports.IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, iModelKey });
59
- this._storage.delete(iModelKey);
53
+ clearStorage(props) {
54
+ const imodelKey = getIModelKey(props);
55
+ this.clearSelection({ source: exports.IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, imodelKey });
56
+ this._storage.delete(imodelKey);
60
57
  }
61
- getContainer(iModelKey) {
62
- let selectionContainer = this._storage.get(iModelKey);
58
+ getContainer(imodelKey) {
59
+ let selectionContainer = this._storage.get(imodelKey);
63
60
  if (!selectionContainer) {
64
61
  selectionContainer = new MultiLevelSelectablesContainer();
65
- this._storage.set(iModelKey, selectionContainer);
62
+ this._storage.set(imodelKey, selectionContainer);
66
63
  }
67
64
  return selectionContainer;
68
65
  }
69
66
  handleChange(props) {
70
- const { iModelKey, source, level: inLevel, changeType, selectables: change } = props;
71
- const container = this.getContainer(iModelKey);
67
+ const { source, level: inLevel, changeType, selectables: change } = props;
68
+ const imodelKey = getIModelKey(props);
69
+ const container = this.getContainer(imodelKey);
72
70
  const level = inLevel ?? 0;
73
71
  const selectables = container.getSelection(level);
74
72
  const selected = Selectable_1.Selectables.create(change);
@@ -100,7 +98,8 @@ class SelectionStorageImpl {
100
98
  const event = {
101
99
  source,
102
100
  level,
103
- iModelKey,
101
+ imodelKey,
102
+ iModelKey: imodelKey,
104
103
  changeType,
105
104
  selectables: selected,
106
105
  timestamp: new Date(),
@@ -108,6 +107,10 @@ class SelectionStorageImpl {
108
107
  this.selectionChangeEvent.raiseEvent(event, this);
109
108
  }
110
109
  }
110
+ function getIModelKey(props) {
111
+ // eslint-disable-next-line deprecation/deprecation
112
+ return "imodelKey" in props ? props.imodelKey : props.iModelKey;
113
+ }
111
114
  class MultiLevelSelectablesContainer {
112
115
  _selectablesContainers;
113
116
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG;;GAEG;AAEH,6CAAuD;AACvD,iEAAqJ;AA+ErJ;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC;AAFD,sCAEC;AAED,gBAAgB;AACH,QAAA,mCAAmC,GAAG,kCAAkC,CAAC;AAEtF,MAAM,oBAAoB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9D,oBAAoB,CAA2B;IAEtD;QACE,IAAI,CAAC,oBAAoB,GAAG,IAAI,+CAAwB,EAAE,CAAC;IAC7D,CAAC;IAEM,kBAAkB,CAAC,EAAE,SAAS,EAAyB;QAC5D,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,kBAAkB,EAAE,CAAC;IAC3D,CAAC;IAEM,YAAY,CAAC,KAA4C;QAC9D,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;QACnC,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;IAEM,cAAc,CAAC,KAAuF;QAC3G,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IAEM,mBAAmB,CAAC,KAAuF;QAChH,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE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D,IAAI,CAAC,WAAW,EAAE;YAChB,WAAW,GAAG,wBAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;SACrD;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,kBAAkB;QACvB,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,EAAE;YACzD,IAAI,CAAC,wBAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBAClC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aACvB;SACF;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,KAAa;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACxD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;YACtC,IAAI,WAAW,IAAI,KAAK,EAAE;gBACxB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,wBAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;aAChC;SACF;IACH,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\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { Selectable, Selectables } from \"./Selectable\";\nimport { SelectionChangeEvent, SelectionChangeEventImpl, StorageSelectionChangeEventArgs, StorageSelectionChangeType } from \"./SelectionChangeEvent\";\n\n/**\n * Defines return value of `createStorage`.\n *\n * @beta Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: SelectionChangeEvent;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: {\n /** Key of the iModel to get selection levels for. */\n iModelKey: string;\n }): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(props: {\n /** Key of the iModel to get selection for. */\n iModelKey: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Replace current selection. */\n replaceSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Clear current selection. */\n clearSelection(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n }): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: {\n /** Key of the iModel to change selection for. */\n iModelKey: string;\n }): void;\n}\n\n/**\n * Creates a selection storage which stores and allows managing application-level selection.\n *\n * **Note:** `clearSelection` should be called upon iModel close to free-up memory:\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * IModelConnection.onClose.addListener((iModel) => {\n * storage.clearStorage(iModel.key);\n * });\n * ```\n *\n * @beta\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\n/** @internal */\nexport const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = \"Unified selection storage: clear\";\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: SelectionChangeEventImpl;\n\n constructor() {\n this.selectionChangeEvent = new SelectionChangeEventImpl();\n }\n\n public getSelectionLevels({ iModelKey }: { iModelKey: string }): number[] {\n return this.getContainer(iModelKey).getSelectionLevels();\n }\n\n public getSelection(props: { iModelKey: string; level?: number }): Selectables {\n const { iModelKey, level } = props;\n return this.getContainer(iModelKey).getSelection(level ?? 0);\n }\n\n public addToSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: { source: string; iModelKey: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: { source: string; iModelKey: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage({ iModelKey }: { iModelKey: string }): void {\n this.clearSelection({ source: IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, iModelKey });\n this._storage.delete(iModelKey);\n }\n\n private getContainer(iModelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(iModelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(iModelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(props: { source: string; iModelKey: string; level?: number; changeType: StorageSelectionChangeType; selectables: Selectable[] }) {\n const { iModelKey, source, level: inLevel, changeType, selectables: change } = props;\n const container = this.getContainer(iModelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n iModelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,6CAAuD;AACvD,iEAAqJ;AAsFrJ;;;;;;;;;;;;GAYG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC;AAFD,sCAEC;AAED,gBA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CAAC;QACtD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,kBAAkB;QACvB,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1D,IAAI,CAAC,wBAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,KAAa;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACxD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,wBAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,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\nimport { Selectable, Selectables } from \"./Selectable\";\nimport { SelectionChangeEvent, SelectionChangeEventImpl, StorageSelectionChangeEventArgs, StorageSelectionChangeType } from \"./SelectionChangeEvent\";\n\ntype IModelKeyProp =\n | {\n /** Key of the iModel to get selection levels for. */\n imodelKey: string;\n }\n | {\n /**\n * Key of the iModel to get selection levels for.\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey: string;\n };\n\n/**\n * Defines return value of `createStorage`.\n *\n * @beta Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: SelectionChangeEvent;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: IModelKeyProp): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(\n props: IModelKeyProp & {\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Replace current selection. */\n replaceSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear current selection. */\n clearSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: IModelKeyProp): void;\n}\n\n/**\n * Creates a selection storage which stores and allows managing application-level selection.\n *\n * **Note:** `clearSelection` should be called upon iModel close to free-up memory:\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * IModelConnection.onClose.addListener((imodel) => {\n * storage.clearStorage(imodel.key);\n * });\n * ```\n *\n * @beta\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\n/** @internal */\nexport const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = \"Unified selection storage: clear\";\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: SelectionChangeEventImpl;\n\n constructor() {\n this.selectionChangeEvent = new SelectionChangeEventImpl();\n }\n\n public getSelectionLevels(props: IModelKeyProp): number[] {\n return this.getContainer(getIModelKey(props)).getSelectionLevels();\n }\n\n public getSelection(props: IModelKeyProp & { level?: number }): Selectables {\n return this.getContainer(getIModelKey(props)).getSelection(props.level ?? 0);\n }\n\n public addToSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: IModelKeyProp & { source: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage(props: IModelKeyProp): void {\n const imodelKey = getIModelKey(props);\n this.clearSelection({ source: IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, imodelKey });\n this._storage.delete(imodelKey);\n }\n\n private getContainer(imodelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(imodelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(imodelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(props: IModelKeyProp & { source: string; level?: number; changeType: StorageSelectionChangeType; selectables: Selectable[] }) {\n const { source, level: inLevel, changeType, selectables: change } = props;\n const imodelKey = getIModelKey(props);\n const container = this.getContainer(imodelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n imodelKey,\n iModelKey: imodelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nfunction getIModelKey(props: IModelKeyProp): string {\n // eslint-disable-next-line deprecation/deprecation\n return \"imodelKey\" in props ? props.imodelKey : props.iModelKey;\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { ECSqlBinding } from "@itwin/presentation-shared";
2
+ /**
3
+ * Forms ECSql bindings from given ID's.
4
+ * @internal
5
+ */
6
+ export declare function formIdBindings(property: string, ids: string[], bindings: ECSqlBinding[]): string;
7
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/Utils.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAYhG"}
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.formIdBindings = void 0;
8
8
  /**
9
9
  * Forms ECSql bindings from given ID's.
10
+ * @internal
10
11
  */
11
12
  function formIdBindings(property, ids, bindings) {
12
13
  if (ids.length > 1000) {
@@ -20,4 +21,4 @@ function formIdBindings(property, ids, bindings) {
20
21
  return `${property} IN (${ids.map(() => "?").join(",")})`;
21
22
  }
22
23
  exports.formIdBindings = formIdBindings;
23
- //# sourceMappingURL=ECSqlCore.js.map
24
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/unified-selection/Utils.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAIhG;;;GAGG;AACH,SAAgB,cAAc,CAAC,QAAgB,EAAE,GAAa,EAAE,QAAwB;IACtF,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,CAAC;QACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7C,OAAO,mBAAmB,QAAQ,GAAG,CAAC;IACxC,CAAC;IAED,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9D,OAAO,GAAG,QAAQ,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAC5D,CAAC;AAZD,wCAYC","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\nimport { ECSqlBinding } from \"@itwin/presentation-shared\";\n\n/**\n * Forms ECSql bindings from given ID's.\n * @internal\n */\nexport function formIdBindings(property: string, ids: string[], bindings: ECSqlBinding[]): string {\n if (ids.length > 1000) {\n bindings.push({ type: \"idset\", value: ids });\n return `InVirtualSet(?, ${property})`;\n }\n\n if (ids.length === 0) {\n return `FALSE`;\n }\n\n ids.forEach((id) => bindings.push({ type: \"id\", value: id }));\n return `${property} IN (${ids.map(() => \"?\").join(\",\")})`;\n}\n"]}
@@ -0,0 +1,84 @@
1
+ import { Id64Arg } from "@itwin/core-bentley";
2
+ import { Event } from "@itwin/presentation-shared";
3
+ /**
4
+ * Identifies the type of changes made to the `CoreIModelSelectionSet` to produce a `CoreSelectionSetEvent`.
5
+ * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/
6
+ * @internal
7
+ */
8
+ export declare enum CoreSelectionSetEventType {
9
+ /** Elements have been added to the set. */
10
+ Add = 0,
11
+ /** Elements have been removed from the set. */
12
+ Remove = 1,
13
+ /** Some elements have been added to the set and others have been removed. */
14
+ Replace = 2,
15
+ /** All elements are about to be removed from the set. */
16
+ Clear = 3
17
+ }
18
+ /**
19
+ * Payload sent to `CoreIModelSelectionSet.onChanged` event listeners to describe how the contents of the set have changed.
20
+ * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionsetevent/
21
+ * @internal
22
+ */
23
+ export interface CoreSelectionSetEventUnsafe {
24
+ /**
25
+ * The type of operation that produced this event.
26
+ *
27
+ * Actually, this should be `CoreSelectionSetEventType`, however we can't use it here because in TS two identical enums with
28
+ * different names aren't equal, so [`SelectionSetEventType `](https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/)
29
+ * doesn't map to `CoreSelectionSetEventType` as far as TS is concerned. Due to this reason, this interface is marked as `unsafe`.
30
+ */
31
+ type: number;
32
+ /** The element Ids added to the set. */
33
+ added?: Id64Arg;
34
+ /** The element Ids removed from the set. */
35
+ removed?: Id64Arg;
36
+ /** The affected `CoreIModelSelectionSet`. */
37
+ set: CoreIModelSelectionSet;
38
+ }
39
+ /**
40
+ * A set of *currently selected* elements in an iModel.
41
+ * @see https://www.itwinjs.org/reference/core-frontend/selectionset/
42
+ * @internal
43
+ */
44
+ export interface CoreIModelSelectionSet {
45
+ /** Event called whenever elements are added or removed from this SelectionSet. */
46
+ onChanged: Event<(ev: CoreSelectionSetEventUnsafe) => void>;
47
+ /** The IDs of the selected elements. */
48
+ readonly elements: Set<string>;
49
+ /** Clear current selection set. */
50
+ emptyAll(): void;
51
+ /** Add one or more Ids to the current selection set. */
52
+ add(elem: Id64Arg): boolean;
53
+ /** Remove one or more Ids from the current selection set. */
54
+ remove(elem: Id64Arg): boolean;
55
+ }
56
+ /**
57
+ * A set if ID's optimized for performance-critical code which represents large sets of ID's as pairs of 32-bit integers.
58
+ * @see https://www.itwinjs.org/reference/core-bentley/ids/id64/id64.uint32set/
59
+ */
60
+ interface Uint32Set {
61
+ /** Add any number of Ids to the set. */
62
+ addIds(ids: Id64Arg): void;
63
+ /** Remove any number of Ids from the set. */
64
+ deleteIds(ids: Id64Arg): void;
65
+ }
66
+ /**
67
+ * A set of *hilited* elements in an iModel, by element id.
68
+ * @see https://www.itwinjs.org/reference/core-frontend/selectionset/hiliteset/
69
+ * @internal
70
+ */
71
+ export interface CoreIModelHiliteSet {
72
+ /** Control whether the hilited elements should be synchronized with the contents of `CoreIModelSelectionSet`.*/
73
+ wantSyncWithSelectionSet: boolean;
74
+ /** The set of hilited elements. */
75
+ readonly elements: Uint32Set;
76
+ /** The set of hilited subcategories. */
77
+ readonly subcategories: Uint32Set;
78
+ /** The set of hilited models. */
79
+ readonly models: Uint32Set;
80
+ /** Remove all elements from the hilited set. */
81
+ clear(): void;
82
+ }
83
+ export {};
84
+ //# sourceMappingURL=IModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModel.d.ts","sourceRoot":"","sources":["../../../../src/unified-selection/types/IModel.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD;;;;GAIG;AACH,oBAAY,yBAAyB;IACnC,2CAA2C;IAC3C,GAAG,IAAA;IACH,+CAA+C;IAC/C,MAAM,IAAA;IACN,6EAA6E;IAC7E,OAAO,IAAA;IACP,yDAAyD;IACzD,KAAK,IAAA;CACN;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6CAA6C;IAC7C,GAAG,EAAE,sBAAsB,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,kFAAkF;IAClF,SAAS,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,2BAA2B,KAAK,IAAI,CAAC,CAAC;IAC5D,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,mCAAmC;IACnC,QAAQ,IAAI,IAAI,CAAC;IACjB,wDAAwD;IACxD,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,6DAA6D;IAC7D,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;CAChC;AAED;;;GAGG;AACH,UAAU,SAAS;IACjB,wCAAwC;IACxC,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,6CAA6C;IAC7C,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,gHAAgH;IAChH,wBAAwB,EAAE,OAAO,CAAC;IAClC,mCAAmC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,wCAAwC;IACxC,QAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;IAClC,iCAAiC;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,gDAAgD;IAChD,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.CoreSelectionSetEventType = void 0;
8
+ /**
9
+ * Identifies the type of changes made to the `CoreIModelSelectionSet` to produce a `CoreSelectionSetEvent`.
10
+ * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/
11
+ * @internal
12
+ */
13
+ var CoreSelectionSetEventType;
14
+ (function (CoreSelectionSetEventType) {
15
+ /** Elements have been added to the set. */
16
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Add"] = 0] = "Add";
17
+ /** Elements have been removed from the set. */
18
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Remove"] = 1] = "Remove";
19
+ /** Some elements have been added to the set and others have been removed. */
20
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Replace"] = 2] = "Replace";
21
+ /** All elements are about to be removed from the set. */
22
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Clear"] = 3] = "Clear";
23
+ })(CoreSelectionSetEventType || (exports.CoreSelectionSetEventType = CoreSelectionSetEventType = {}));
24
+ //# sourceMappingURL=IModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModel.js","sourceRoot":"","sources":["../../../../src/unified-selection/types/IModel.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAKhG;;;;GAIG;AACH,IAAY,yBASX;AATD,WAAY,yBAAyB;IACnC,2CAA2C;IAC3C,uEAAG,CAAA;IACH,+CAA+C;IAC/C,6EAAM,CAAA;IACN,6EAA6E;IAC7E,+EAAO,CAAA;IACP,yDAAyD;IACzD,2EAAK,CAAA;AACP,CAAC,EATW,yBAAyB,yCAAzB,yBAAyB,QASpC","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\nimport { Id64Arg } from \"@itwin/core-bentley\";\nimport { Event } from \"@itwin/presentation-shared\";\n\n/**\n * Identifies the type of changes made to the `CoreIModelSelectionSet` to produce a `CoreSelectionSetEvent`.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/\n * @internal\n */\nexport enum CoreSelectionSetEventType {\n /** Elements have been added to the set. */\n Add,\n /** Elements have been removed from the set. */\n Remove,\n /** Some elements have been added to the set and others have been removed. */\n Replace,\n /** All elements are about to be removed from the set. */\n Clear,\n}\n\n/**\n * Payload sent to `CoreIModelSelectionSet.onChanged` event listeners to describe how the contents of the set have changed.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionsetevent/\n * @internal\n */\nexport interface CoreSelectionSetEventUnsafe {\n /**\n * The type of operation that produced this event.\n *\n * Actually, this should be `CoreSelectionSetEventType`, however we can't use it here because in TS two identical enums with\n * different names aren't equal, so [`SelectionSetEventType `](https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/)\n * doesn't map to `CoreSelectionSetEventType` as far as TS is concerned. Due to this reason, this interface is marked as `unsafe`.\n */\n type: number;\n /** The element Ids added to the set. */\n added?: Id64Arg;\n /** The element Ids removed from the set. */\n removed?: Id64Arg;\n /** The affected `CoreIModelSelectionSet`. */\n set: CoreIModelSelectionSet;\n}\n\n/**\n * A set of *currently selected* elements in an iModel.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/\n * @internal\n */\nexport interface CoreIModelSelectionSet {\n /** Event called whenever elements are added or removed from this SelectionSet. */\n onChanged: Event<(ev: CoreSelectionSetEventUnsafe) => void>;\n /** The IDs of the selected elements. */\n readonly elements: Set<string>;\n /** Clear current selection set. */\n emptyAll(): void;\n /** Add one or more Ids to the current selection set. */\n add(elem: Id64Arg): boolean;\n /** Remove one or more Ids from the current selection set. */\n remove(elem: Id64Arg): boolean;\n}\n\n/**\n * A set if ID's optimized for performance-critical code which represents large sets of ID's as pairs of 32-bit integers.\n * @see https://www.itwinjs.org/reference/core-bentley/ids/id64/id64.uint32set/\n */\ninterface Uint32Set {\n /** Add any number of Ids to the set. */\n addIds(ids: Id64Arg): void;\n /** Remove any number of Ids from the set. */\n deleteIds(ids: Id64Arg): void;\n}\n\n/**\n * A set of *hilited* elements in an iModel, by element id.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/hiliteset/\n * @internal\n */\nexport interface CoreIModelHiliteSet {\n /** Control whether the hilited elements should be synchronized with the contents of `CoreIModelSelectionSet`.*/\n wantSyncWithSelectionSet: boolean;\n /** The set of hilited elements. */\n readonly elements: Uint32Set;\n /** The set of hilited subcategories. */\n readonly subcategories: Uint32Set;\n /** The set of hilited models. */\n readonly models: Uint32Set;\n /** Remove all elements from the hilited set. */\n clear(): void;\n}\n"]}
@@ -1,13 +1,8 @@
1
- /**
2
- * @module UnifiedSelection
3
- *
4
- * @docs-group-description UnifiedSelection
5
- * API for working with unified selection.
6
- */
7
1
  export * from "./unified-selection/Selectable";
8
2
  export { SelectionStorage, createStorage } from "./unified-selection/SelectionStorage";
9
3
  export { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from "./unified-selection/HiliteSetProvider";
10
4
  export { createCachingHiliteSetProvider, CachingHiliteSetProvider } from "./unified-selection/CachingHiliteSetProvider";
11
5
  export { computeSelection } from "./unified-selection/SelectionScope";
6
+ export { enableUnifiedSelectionSyncWithIModel } from "./unified-selection/EnableUnifiedSelectionSyncWithIModel";
12
7
  export { StorageSelectionChangeType, StorageSelectionChangeEventArgs, StorageSelectionChangesListener, SelectionChangeEvent, } from "./unified-selection/SelectionChangeEvent";
13
8
  //# sourceMappingURL=unified-selection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,0CAA0C,CAAC"}
1
+ {"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,0DAA0D,CAAC;AAChH,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,0CAA0C,CAAC"}
@@ -18,13 +18,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.computeSelection = exports.createCachingHiliteSetProvider = exports.createHiliteSetProvider = exports.createStorage = void 0;
22
- /**
23
- * @module UnifiedSelection
24
- *
25
- * @docs-group-description UnifiedSelection
26
- * API for working with unified selection.
27
- */
21
+ exports.enableUnifiedSelectionSyncWithIModel = exports.computeSelection = exports.createCachingHiliteSetProvider = exports.createHiliteSetProvider = exports.createStorage = void 0;
28
22
  __exportStar(require("./unified-selection/Selectable"), exports);
29
23
  var SelectionStorage_1 = require("./unified-selection/SelectionStorage");
30
24
  Object.defineProperty(exports, "createStorage", { enumerable: true, get: function () { return SelectionStorage_1.createStorage; } });
@@ -34,4 +28,6 @@ var CachingHiliteSetProvider_1 = require("./unified-selection/CachingHiliteSetPr
34
28
  Object.defineProperty(exports, "createCachingHiliteSetProvider", { enumerable: true, get: function () { return CachingHiliteSetProvider_1.createCachingHiliteSetProvider; } });
35
29
  var SelectionScope_1 = require("./unified-selection/SelectionScope");
36
30
  Object.defineProperty(exports, "computeSelection", { enumerable: true, get: function () { return SelectionScope_1.computeSelection; } });
31
+ var EnableUnifiedSelectionSyncWithIModel_1 = require("./unified-selection/EnableUnifiedSelectionSyncWithIModel");
32
+ Object.defineProperty(exports, "enableUnifiedSelectionSyncWithIModel", { enumerable: true, get: function () { return EnableUnifiedSelectionSyncWithIModel_1.enableUnifiedSelectionSyncWithIModel; } });
37
33
  //# sourceMappingURL=unified-selection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;AAEhG;;;;;GAKG;AACH,iEAA+C;AAC/C,yEAAuF;AAA5D,iHAAA,aAAa,OAAA;AACxC,2EAA8G;AAArG,4HAAA,uBAAuB,OAAA;AAChC,yFAAwH;AAA/G,0IAAA,8BAA8B,OAAA;AACvC,qEAAsE;AAA7D,kHAAA,gBAAgB,OAAA","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/**\n * @module UnifiedSelection\n *\n * @docs-group-description UnifiedSelection\n * API for working with unified selection.\n */\nexport * from \"./unified-selection/Selectable\";\nexport { SelectionStorage, createStorage } from \"./unified-selection/SelectionStorage\";\nexport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider\";\nexport { createCachingHiliteSetProvider, CachingHiliteSetProvider } from \"./unified-selection/CachingHiliteSetProvider\";\nexport { computeSelection } from \"./unified-selection/SelectionScope\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n SelectionChangeEvent,\n} from \"./unified-selection/SelectionChangeEvent\";\n"]}
1
+ {"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;AAEhG,iEAA+C;AAC/C,yEAAuF;AAA5D,iHAAA,aAAa,OAAA;AACxC,2EAA8G;AAArG,4HAAA,uBAAuB,OAAA;AAChC,yFAAwH;AAA/G,0IAAA,8BAA8B,OAAA;AACvC,qEAAsE;AAA7D,kHAAA,gBAAgB,OAAA;AACzB,iHAAgH;AAAvG,4JAAA,oCAAoC,OAAA","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\nexport * from \"./unified-selection/Selectable\";\nexport { SelectionStorage, createStorage } from \"./unified-selection/SelectionStorage\";\nexport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider\";\nexport { createCachingHiliteSetProvider, CachingHiliteSetProvider } from \"./unified-selection/CachingHiliteSetProvider\";\nexport { computeSelection } from \"./unified-selection/SelectionScope\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n SelectionChangeEvent,\n} from \"./unified-selection/SelectionChangeEvent\";\n"]}
@@ -1,6 +1,5 @@
1
+ import { ECSchemaProvider, ECSqlQueryExecutor } from "@itwin/presentation-shared";
1
2
  import { HiliteSet } from "./HiliteSetProvider";
2
- import { IMetadataProvider } from "./queries/ECMetadata";
3
- import { IECSqlQueryExecutor } from "./queries/ECSqlCore";
4
3
  import { SelectionStorage } from "./SelectionStorage";
5
4
  /**
6
5
  * Props for creating a `CachingHiliteSetProvider` instance.
@@ -8,10 +7,7 @@ import { SelectionStorage } from "./SelectionStorage";
8
7
  */
9
8
  export interface CachingHiliteSetProviderProps {
10
9
  selectionStorage: SelectionStorage;
11
- iModelProvider: (iModelKey: string) => {
12
- queryExecutor: IECSqlQueryExecutor;
13
- metadataProvider: IMetadataProvider;
14
- };
10
+ imodelProvider: (imodelKey: string) => ECSchemaProvider & ECSqlQueryExecutor;
15
11
  }
16
12
  /**
17
13
  * Defines return value of `createCachingHiliteSetProvider`.
@@ -23,7 +19,7 @@ export interface CachingHiliteSetProvider {
23
19
  /** Get the current hilite set iterator for the specified imodel */
24
20
  getHiliteSet(props: {
25
21
  /** iModel to get hilite set for */
26
- iModelKey: string;
22
+ imodelKey: string;
27
23
  }): AsyncIterableIterator<HiliteSet>;
28
24
  /** Disposes the cache. */
29
25
  dispose(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"CachingHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAWA,OAAO,EAA2B,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAuC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3F;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK;QAAE,aAAa,EAAE,mBAAmB,CAAC;QAAC,gBAAgB,EAAE,iBAAiB,CAAA;KAAE,CAAC;CACpH;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,mEAAmE;IACnE,YAAY,CAAC,KAAK,EAAE;QAClB,mCAAmC;QACnC,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAErC,0BAA0B;IAC1B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,6BAA6B,GAAG,wBAAwB,CAE7G"}
1
+ {"version":3,"file":"CachingHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAA2B,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AAE5F,OAAO,EAAuC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3F;;;GAGG;AACH,MAAM,WAAW,6BAA6B;IAC5C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,gBAAgB,GAAG,kBAAkB,CAAC;CAC9E;AAED;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC,mEAAmE;IACnE,YAAY,CAAC,KAAK,EAAE;QAClB,mCAAmC;QACnC,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAErC,0BAA0B;IAC1B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,6BAA6B,GAAG,wBAAwB,CAE7G"}
@@ -2,9 +2,6 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module UnifiedSelection
7
- */
8
5
  import { from, shareReplay } from "rxjs";
9
6
  import { eachValueFrom } from "rxjs-for-await";
10
7
  import { createHiliteSetProvider } from "./HiliteSetProvider";
@@ -22,25 +19,25 @@ class CachingHiliteSetProviderImpl {
22
19
  _hiliteSetProviders = new Map();
23
20
  _cache = new Map();
24
21
  _removeListener;
25
- _iModelProvider;
22
+ _imodelProvider;
26
23
  constructor(props) {
27
24
  this._selectionStorage = props.selectionStorage;
28
- this._iModelProvider = props.iModelProvider;
25
+ this._imodelProvider = props.imodelProvider;
29
26
  this._removeListener = this._selectionStorage.selectionChangeEvent.addListener((args) => {
30
- this._cache.delete(args.iModelKey);
27
+ this._cache.delete(args.imodelKey);
31
28
  if (args.changeType === "clear" && args.source === IMODEL_CLOSE_SELECTION_CLEAR_SOURCE) {
32
- this._hiliteSetProviders.delete(args.iModelKey);
29
+ this._hiliteSetProviders.delete(args.imodelKey);
33
30
  }
34
31
  });
35
32
  }
36
- getHiliteSet({ iModelKey }) {
37
- const { queryExecutor, metadataProvider } = this._iModelProvider(iModelKey);
38
- const provider = this.getHiliteSetProvider(iModelKey, queryExecutor, metadataProvider);
39
- let hiliteSet = this._cache.get(iModelKey);
33
+ getHiliteSet({ imodelKey }) {
34
+ const imodelAccess = this._imodelProvider(imodelKey);
35
+ const provider = this.getHiliteSetProvider(imodelKey, imodelAccess);
36
+ let hiliteSet = this._cache.get(imodelKey);
40
37
  if (!hiliteSet) {
41
- const selectables = this._selectionStorage.getSelection({ iModelKey });
38
+ const selectables = this._selectionStorage.getSelection({ imodelKey });
42
39
  hiliteSet = from(provider.getHiliteSet({ selectables })).pipe(shareReplay({ refCount: true }));
43
- this._cache.set(iModelKey, hiliteSet);
40
+ this._cache.set(imodelKey, hiliteSet);
44
41
  }
45
42
  return eachValueFrom(hiliteSet);
46
43
  }
@@ -49,11 +46,11 @@ class CachingHiliteSetProviderImpl {
49
46
  this._hiliteSetProviders = new Map();
50
47
  this._cache = new Map();
51
48
  }
52
- getHiliteSetProvider(iModelKey, queryExecutor, metadataProvider) {
53
- let provider = this._hiliteSetProviders.get(iModelKey);
49
+ getHiliteSetProvider(imodelKey, imodelAccess) {
50
+ let provider = this._hiliteSetProviders.get(imodelKey);
54
51
  if (!provider) {
55
- provider = createHiliteSetProvider({ queryExecutor, metadataProvider });
56
- this._hiliteSetProviders.set(iModelKey, provider);
52
+ provider = createHiliteSetProvider({ imodelAccess });
53
+ this._hiliteSetProviders.set(imodelKey, provider);
57
54
  }
58
55
  return provider;
59
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CachingHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAgC,MAAM,qBAAqB,CAAC;AAI5F,OAAO,EAAE,mCAAmC,EAAoB,MAAM,oBAAoB,CAAC;AA4B3F;;;;GAIG;AACH,MAAM,UAAU,8BAA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,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/F,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;SACvC;QAED,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,CAAC;IAEO,oBAAoB,CAAC,SAAiB,EAAE,aAAkC,EAAE,gBAAmC;QACrH,IAAI,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,EAAE;YACb,QAAQ,GAAG,uBAAuB,CAAC,EAAE,aAAa,EAAE,gBAAgB,EAAE,CAAC,CAAC;YACxE,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;SACnD;QACD,OAAO,QAAQ,CAAC;IAClB,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\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { from, Observable, shareReplay } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\nimport { IMetadataProvider } from \"./queries/ECMetadata\";\nimport { IECSqlQueryExecutor } from \"./queries/ECSqlCore\";\nimport { StorageSelectionChangeEventArgs } from \"./SelectionChangeEvent\";\nimport { IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, SelectionStorage } from \"./SelectionStorage\";\n\n/**\n * Props for creating a `CachingHiliteSetProvider` instance.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface CachingHiliteSetProviderProps {\n selectionStorage: SelectionStorage;\n iModelProvider: (iModelKey: string) => { queryExecutor: IECSqlQueryExecutor; metadataProvider: IMetadataProvider };\n}\n\n/**\n * Defines return value of `createCachingHiliteSetProvider`.\n *\n * @beta Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface CachingHiliteSetProvider {\n /** Get the current hilite set iterator for the specified imodel */\n getHiliteSet(props: {\n /** iModel to get hilite set for */\n iModelKey: string;\n }): AsyncIterableIterator<HiliteSet>;\n\n /** Disposes the cache. */\n dispose(): void;\n}\n\n/**\n * Creates a hilite set provider that caches hilite set for current selection for given iModel so any subsequent\n * hilite set requests for the same iModel don't cost until selection in given selection storage changes.\n * @beta\n */\nexport function createCachingHiliteSetProvider(props: CachingHiliteSetProviderProps): CachingHiliteSetProvider {\n return new CachingHiliteSetProviderImpl(props);\n}\n\nclass CachingHiliteSetProviderImpl implements CachingHiliteSetProvider {\n private _selectionStorage: SelectionStorage;\n private _hiliteSetProviders = new Map<string, HiliteSetProvider>();\n private _cache = new Map<string, Observable<HiliteSet>>();\n private _removeListener: () => void;\n private _iModelProvider: (iModelKey: string) => { queryExecutor: IECSqlQueryExecutor; metadataProvider: IMetadataProvider };\n\n constructor(props: CachingHiliteSetProviderProps) {\n this._selectionStorage = props.selectionStorage;\n this._iModelProvider = props.iModelProvider;\n this._removeListener = this._selectionStorage.selectionChangeEvent.addListener((args: StorageSelectionChangeEventArgs) => {\n this._cache.delete(args.iModelKey);\n if (args.changeType === \"clear\" && args.source === IMODEL_CLOSE_SELECTION_CLEAR_SOURCE) {\n this._hiliteSetProviders.delete(args.iModelKey);\n }\n });\n }\n\n public getHiliteSet({ iModelKey }: { iModelKey: string }): AsyncIterableIterator<HiliteSet> {\n const { queryExecutor, metadataProvider } = this._iModelProvider(iModelKey);\n const provider = this.getHiliteSetProvider(iModelKey, queryExecutor, metadataProvider);\n let hiliteSet = this._cache.get(iModelKey);\n\n if (!hiliteSet) {\n const selectables = this._selectionStorage.getSelection({ iModelKey });\n hiliteSet = from(provider.getHiliteSet({ selectables })).pipe(shareReplay({ refCount: true }));\n this._cache.set(iModelKey, hiliteSet);\n }\n\n return eachValueFrom(hiliteSet);\n }\n\n public dispose(): void {\n this._removeListener();\n this._hiliteSetProviders = new Map();\n this._cache = new Map();\n }\n\n private getHiliteSetProvider(iModelKey: string, queryExecutor: IECSqlQueryExecutor, metadataProvider: IMetadataProvider) {\n let provider = this._hiliteSetProviders.get(iModelKey);\n if (!provider) {\n provider = createHiliteSetProvider({ queryExecutor, metadataProvider });\n this._hiliteSetProviders.set(iModelKey, provider);\n }\n return provider;\n }\n}\n"]}
1
+ {"version":3,"file":"CachingHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAgC,MAAM,qBAAqB,CAAC;AAE5F,OAAO,EAAE,mCAAmC,EAAoB,MAAM,oBAAoB,CAAC;AA4B3F;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAAoC;IACjF,OAAO,IAAI,4BAA4B,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,MAAM,4BAA4B;IACxB,iBAAiB,CAAmB;IACpC,mBAAmB,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC3D,MAAM,GAAG,IAAI,GAAG,EAAiC,CAAC;IAClD,eAAe,CAAa;IAC5B,eAAe,CAA+D;IAEtF,YAAY,KAAoC;QAC9C,IAAI,CAAC,iBA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ACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,CAAC;IAEO,oBAAoB,CAAC,SAAiB,EAAE,YAAmD;QACjG,IAAI,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,uBAAuB,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,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\nimport { from, Observable, shareReplay } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { ECSchemaProvider, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\nimport { StorageSelectionChangeEventArgs } from \"./SelectionChangeEvent\";\nimport { IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, SelectionStorage } from \"./SelectionStorage\";\n\n/**\n * Props for creating a `CachingHiliteSetProvider` instance.\n * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.\n */\nexport interface CachingHiliteSetProviderProps {\n selectionStorage: SelectionStorage;\n imodelProvider: (imodelKey: string) => ECSchemaProvider & ECSqlQueryExecutor;\n}\n\n/**\n * Defines return value of `createCachingHiliteSetProvider`.\n *\n * @beta Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n */\nexport interface CachingHiliteSetProvider {\n /** Get the current hilite set iterator for the specified imodel */\n getHiliteSet(props: {\n /** iModel to get hilite set for */\n imodelKey: string;\n }): AsyncIterableIterator<HiliteSet>;\n\n /** Disposes the cache. */\n dispose(): void;\n}\n\n/**\n * Creates a hilite set provider that caches hilite set for current selection for given iModel so any subsequent\n * hilite set requests for the same iModel don't cost until selection in given selection storage changes.\n * @beta\n */\nexport function createCachingHiliteSetProvider(props: CachingHiliteSetProviderProps): CachingHiliteSetProvider {\n return new CachingHiliteSetProviderImpl(props);\n}\n\nclass CachingHiliteSetProviderImpl implements CachingHiliteSetProvider {\n private _selectionStorage: SelectionStorage;\n private _hiliteSetProviders = new Map<string, HiliteSetProvider>();\n private _cache = new Map<string, Observable<HiliteSet>>();\n private _removeListener: () => void;\n private _imodelProvider: (imodelKey: string) => ECSchemaProvider & ECSqlQueryExecutor;\n\n constructor(props: CachingHiliteSetProviderProps) {\n this._selectionStorage = props.selectionStorage;\n this._imodelProvider = props.imodelProvider;\n this._removeListener = this._selectionStorage.selectionChangeEvent.addListener((args: StorageSelectionChangeEventArgs) => {\n this._cache.delete(args.imodelKey);\n if (args.changeType === \"clear\" && args.source === IMODEL_CLOSE_SELECTION_CLEAR_SOURCE) {\n this._hiliteSetProviders.delete(args.imodelKey);\n }\n });\n }\n\n public getHiliteSet({ imodelKey }: { imodelKey: string }): AsyncIterableIterator<HiliteSet> {\n const imodelAccess = this._imodelProvider(imodelKey);\n const provider = this.getHiliteSetProvider(imodelKey, imodelAccess);\n let hiliteSet = this._cache.get(imodelKey);\n\n if (!hiliteSet) {\n const selectables = this._selectionStorage.getSelection({ imodelKey });\n hiliteSet = from(provider.getHiliteSet({ selectables })).pipe(shareReplay({ refCount: true }));\n this._cache.set(imodelKey, hiliteSet);\n }\n\n return eachValueFrom(hiliteSet);\n }\n\n public dispose(): void {\n this._removeListener();\n this._hiliteSetProviders = new Map();\n this._cache = new Map();\n }\n\n private getHiliteSetProvider(imodelKey: string, imodelAccess: ECSchemaProvider & ECSqlQueryExecutor) {\n let provider = this._hiliteSetProviders.get(imodelKey);\n if (!provider) {\n provider = createHiliteSetProvider({ imodelAccess });\n this._hiliteSetProviders.set(imodelKey, provider);\n }\n return provider;\n }\n}\n"]}
@@ -0,0 +1,90 @@
1
+ import { ECSchemaProvider, ECSqlQueryExecutor } from "@itwin/presentation-shared";
2
+ import { CachingHiliteSetProvider } from "./CachingHiliteSetProvider";
3
+ import { ComputeSelectionProps } from "./SelectionScope";
4
+ import { SelectionStorage } from "./SelectionStorage";
5
+ import { CoreIModelHiliteSet, CoreIModelSelectionSet } from "./types/IModel";
6
+ /**
7
+ * Props for `enableUnifiedSelectionSyncWithIModel`.
8
+ * @internal Not exported through barrel, but used in public API as an argument. May be supplemented with optional attributes any time.
9
+ */
10
+ export interface EnableUnifiedSelectionSyncWithIModelProps {
11
+ /**
12
+ * Provides access to different iModel's features: query executing, metadata access, selection and hilite sets.
13
+ * It's recommended to use `@itwin/presentation-core-interop` to create `ECSqlQueryExecutor` and `ECSchemaProvider` from
14
+ * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/) and map its `key`,
15
+ * `hilited` and `selectionSet` attributes like this:
16
+ *
17
+ * ```ts
18
+ * import { createECSqlQueryExecutor, createECSchemaProvider } from "@itwin/presentation-core-interop";
19
+ * import { IModelConnection } from "@itwin/core-frontend";
20
+ *
21
+ * const imodel: IModelConnection = ...
22
+ * const imodelAccess = {
23
+ * ...createECSqlQueryExecutor(imodel),
24
+ * ...createECSchemaProvider(MyAppFrontend.getSchemaContext(imodel)),
25
+ * key: imodel.key,
26
+ * hiliteSet: imodel.hilited,
27
+ * selectionSet: imodel.selectionSet,
28
+ * };
29
+ * ```.
30
+ */
31
+ imodelAccess: ECSqlQueryExecutor & ECSchemaProvider & {
32
+ /** Key of the iModel. Generally taken from `IModelConnection.key`. */
33
+ readonly key: string;
34
+ /** The set of currently hilited elements taken from `IModelConnection.hilited`. */
35
+ readonly hiliteSet: CoreIModelHiliteSet;
36
+ /** The set of currently selected elements taken from `IModelConnection.selectionSet`. */
37
+ readonly selectionSet: CoreIModelSelectionSet;
38
+ };
39
+ /** Selection storage to synchronize IModel's tool selection with. */
40
+ selectionStorage: SelectionStorage;
41
+ /** Active scope provider. */
42
+ activeScopeProvider: () => ComputeSelectionProps["scope"];
43
+ /**
44
+ * A caching hilite set provider used to retrieve hilite sets for an iModel. If not provided, a new `CachingHiliteSetProvider`
45
+ * will be created for the given iModel using the provided `imodelAccess`.
46
+ * If the consuming application already has a `CachingHiliteSetProvider` defined, it should be provided instead
47
+ * to reuse the cache and avoid creating new providers for each iModel.
48
+ */
49
+ cachingHiliteSetProvider?: CachingHiliteSetProvider;
50
+ }
51
+ /**
52
+ * Enables synchronization between iModel selection and unified selection.
53
+ * @returns function for disposing the synchronization.
54
+ * @beta
55
+ */
56
+ export declare function enableUnifiedSelectionSyncWithIModel(props: EnableUnifiedSelectionSyncWithIModelProps): () => void;
57
+ /**
58
+ * A handler that syncs selection between unified selection storage
59
+ * (`SelectionStorage`) and an iModel (`iModel.selectionSet`, `iModel.hilited`).
60
+ * @internal
61
+ */
62
+ export declare class IModelSelectionHandler {
63
+ private _selectionSourceName;
64
+ private _imodelAccess;
65
+ private _selectionStorage;
66
+ private _hiliteSetProvider;
67
+ private _cachingHiliteSetProvider;
68
+ private _activeScopeProvider;
69
+ private _isSuspended;
70
+ private _cancelOngoingChanges;
71
+ private _unifiedSelectionListenerDisposeFunc;
72
+ private _imodelListenerDisposeFunc;
73
+ private _hasCustomCachingHiliteSetProvider;
74
+ constructor(props: EnableUnifiedSelectionSyncWithIModelProps);
75
+ dispose(): void;
76
+ /** Temporarily suspends tool selection synchronization until the returned `IDisposable` is disposed. */
77
+ suspendIModelToolSelectionSync(): {
78
+ dispose: () => boolean;
79
+ };
80
+ private handleUnifiedSelectionChange;
81
+ private onUnifiedSelectionChanged;
82
+ private applyCurrentHiliteSet;
83
+ private addHiliteSet;
84
+ private removeHiliteSet;
85
+ private onIModelSelectionChanged;
86
+ private handleIModelSelectionChange;
87
+ private getSelectionSetChangeIds;
88
+ private idArgToIds;
89
+ }
90
+ //# sourceMappingURL=EnableUnifiedSelectionSyncWithIModel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnableUnifiedSelectionSyncWithIModel.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/EnableUnifiedSelectionSyncWithIModel.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAkC,MAAM,4BAA4B,CAAC;AAItG,OAAO,EAAoB,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAA0D,MAAM,gBAAgB,CAAC;AAErI;;;GAGG;AACH,MAAM,WAAW,yCAAyC;IACxD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,YAAY,EAAE,kBAAkB,GAC9B,gBAAgB,GAAG;QACjB,sEAAsE;QACtE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QACrB,mFAAmF;QACnF,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;QACxC,yFAAyF;QACzF,QAAQ,CAAC,YAAY,EAAE,sBAAsB,CAAC;KAC/C,CAAC;IAEJ,qEAAqE;IACrE,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,6BAA6B;IAC7B,mBAAmB,EAAE,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAE1D;;;;;OAKG;IACH,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;CACrD;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,yCAAyC,GAAG,MAAM,IAAI,CAGjH;AAED;;;;GAIG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,oBAAoB,CAAU;IAEtC,OAAO,CAAC,aAAa,CAA4D;IACjF,OA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