@itwin/unified-selection 1.6.9-alpha.0 → 1.7.1-alpha.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 (57) hide show
  1. package/CHANGELOG.md +14 -59
  2. package/README.md +5 -1
  3. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -1
  4. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +2 -2
  5. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +1 -1
  6. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -1
  7. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +28 -15
  8. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -1
  9. package/lib/cjs/unified-selection/HiliteSetProvider.js +12 -3
  10. package/lib/cjs/unified-selection/HiliteSetProvider.js.map +1 -1
  11. package/lib/cjs/unified-selection/IModelHiliteSetProvider.js +2 -1
  12. package/lib/cjs/unified-selection/IModelHiliteSetProvider.js.map +1 -1
  13. package/lib/cjs/unified-selection/Selectable.d.ts.map +1 -1
  14. package/lib/cjs/unified-selection/Selectable.js.map +1 -1
  15. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts +6 -1
  16. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  17. package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +1 -1
  18. package/lib/cjs/unified-selection/SelectionScope.d.ts.map +1 -1
  19. package/lib/cjs/unified-selection/SelectionScope.js +1 -4
  20. package/lib/cjs/unified-selection/SelectionScope.js.map +1 -1
  21. package/lib/cjs/unified-selection/SelectionStorage.d.ts +15 -4
  22. package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
  23. package/lib/cjs/unified-selection/SelectionStorage.js +1 -1
  24. package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
  25. package/lib/cjs/unified-selection/Utils.d.ts.map +1 -1
  26. package/lib/cjs/unified-selection/Utils.js.map +1 -1
  27. package/lib/cjs/unified-selection.d.ts +1 -1
  28. package/lib/cjs/unified-selection.d.ts.map +1 -1
  29. package/lib/cjs/unified-selection.js.map +1 -1
  30. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -1
  31. package/lib/esm/unified-selection/CachingHiliteSetProvider.js +2 -2
  32. package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +1 -1
  33. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -1
  34. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +28 -15
  35. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -1
  36. package/lib/esm/unified-selection/HiliteSetProvider.js +12 -3
  37. package/lib/esm/unified-selection/HiliteSetProvider.js.map +1 -1
  38. package/lib/esm/unified-selection/IModelHiliteSetProvider.js +2 -1
  39. package/lib/esm/unified-selection/IModelHiliteSetProvider.js.map +1 -1
  40. package/lib/esm/unified-selection/Selectable.d.ts.map +1 -1
  41. package/lib/esm/unified-selection/Selectable.js.map +1 -1
  42. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +6 -1
  43. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  44. package/lib/esm/unified-selection/SelectionChangeEvent.js.map +1 -1
  45. package/lib/esm/unified-selection/SelectionScope.d.ts.map +1 -1
  46. package/lib/esm/unified-selection/SelectionScope.js +1 -4
  47. package/lib/esm/unified-selection/SelectionScope.js.map +1 -1
  48. package/lib/esm/unified-selection/SelectionStorage.d.ts +15 -4
  49. package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
  50. package/lib/esm/unified-selection/SelectionStorage.js +1 -1
  51. package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
  52. package/lib/esm/unified-selection/Utils.d.ts.map +1 -1
  53. package/lib/esm/unified-selection/Utils.js.map +1 -1
  54. package/lib/esm/unified-selection.d.ts +1 -1
  55. package/lib/esm/unified-selection.d.ts.map +1 -1
  56. package/lib/esm/unified-selection.js.map +1 -1
  57. package/package.json +13 -21
@@ -11,5 +11,5 @@ export { createIModelHiliteSetProvider } from "./unified-selection/IModelHiliteS
11
11
  export type { SelectionScope } from "./unified-selection/SelectionScope.js";
12
12
  export { computeSelection } from "./unified-selection/SelectionScope.js";
13
13
  export { enableUnifiedSelectionSyncWithIModel } from "./unified-selection/EnableUnifiedSelectionSyncWithIModel.js";
14
- export type { StorageSelectionChangeType, StorageSelectionChangeEventArgs, StorageSelectionChangesListener } from "./unified-selection/SelectionChangeEvent.js";
14
+ export type { StorageSelectionChangeType, StorageSelectionChangeEventArgs, StorageSelectionChangesListener, } from "./unified-selection/SelectionChangeEvent.js";
15
15
  //# 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,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AACvH,OAAO,EAAE,2BAA2B,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACzG,YAAY,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,YAAY,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAEhG,OAAO,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AACjG,YAAY,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,YAAY,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,YAAY,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC"}
1
+ {"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA,YAAY,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AACvH,OAAO,EAAE,2BAA2B,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AACzG,YAAY,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,YAAY,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAEhG,OAAO,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AACjG,YAAY,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AAC9F,OAAO,EAAE,6BAA6B,EAAE,MAAM,gDAAgD,CAAC;AAC/F,YAAY,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,YAAY,EACV,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,6CAA6C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,mEAAyG;AAAhG,4HAAA,2BAA2B,OAAA;AAAE,2GAAA,UAAU,OAAA;AAAE,4GAAA,WAAW,OAAA;AAE7D,+EAAwE;AAA/D,oHAAA,aAAa,OAAA;AAEtB,iFAAmF;AAA1E,+HAAA,uBAAuB,OAAA;AAGhC,4DAA4D;AAC5D,+FAAiG;AAAxF,6IAAA,8BAA8B,OAAA;AAEvC,6FAA+F;AAAtF,2IAAA,6BAA6B,OAAA;AAEtC,2EAAyE;AAAhE,qHAAA,gBAAgB,OAAA;AACzB,uHAAmH;AAA1G,+JAAA,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 type { CustomSelectable, SelectableIdentifier, SelectableInstanceKey } from \"./unified-selection/Selectable.js\";\nexport { TRANSIENT_ELEMENT_CLASSNAME, Selectable, Selectables } from \"./unified-selection/Selectable.js\";\nexport type { SelectionStorage } from \"./unified-selection/SelectionStorage.js\";\nexport { createStorage } from \"./unified-selection/SelectionStorage.js\";\nexport type { HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\nexport { createHiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { CachingHiliteSetProvider } from \"./unified-selection/CachingHiliteSetProvider.js\";\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { createCachingHiliteSetProvider } from \"./unified-selection/CachingHiliteSetProvider.js\";\nexport type { IModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport { createIModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport type { SelectionScope } from \"./unified-selection/SelectionScope.js\";\nexport { computeSelection } from \"./unified-selection/SelectionScope.js\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel.js\";\nexport type { StorageSelectionChangeType, StorageSelectionChangeEventArgs, StorageSelectionChangesListener } from \"./unified-selection/SelectionChangeEvent.js\";\n"]}
1
+ {"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAGhG,mEAAyG;AAAhG,4HAAA,2BAA2B,OAAA;AAAE,2GAAA,UAAU,OAAA;AAAE,4GAAA,WAAW,OAAA;AAE7D,+EAAwE;AAA/D,oHAAA,aAAa,OAAA;AAEtB,iFAAmF;AAA1E,+HAAA,uBAAuB,OAAA;AAGhC,4DAA4D;AAC5D,+FAAiG;AAAxF,6IAAA,8BAA8B,OAAA;AAEvC,6FAA+F;AAAtF,2IAAA,6BAA6B,OAAA;AAEtC,2EAAyE;AAAhE,qHAAA,gBAAgB,OAAA;AACzB,uHAAmH;AAA1G,+JAAA,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 type { CustomSelectable, SelectableIdentifier, SelectableInstanceKey } from \"./unified-selection/Selectable.js\";\nexport { TRANSIENT_ELEMENT_CLASSNAME, Selectable, Selectables } from \"./unified-selection/Selectable.js\";\nexport type { SelectionStorage } from \"./unified-selection/SelectionStorage.js\";\nexport { createStorage } from \"./unified-selection/SelectionStorage.js\";\nexport type { HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\nexport { createHiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport type { CachingHiliteSetProvider } from \"./unified-selection/CachingHiliteSetProvider.js\";\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport { createCachingHiliteSetProvider } from \"./unified-selection/CachingHiliteSetProvider.js\";\nexport type { IModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport { createIModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport type { SelectionScope } from \"./unified-selection/SelectionScope.js\";\nexport { computeSelection } from \"./unified-selection/SelectionScope.js\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel.js\";\nexport type {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n} from \"./unified-selection/SelectionChangeEvent.js\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CachingHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAMA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,8DAA8D;IAC9D,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,iEAAiE;IACjE,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,GAAG,kBAAkB,CAAC;IAEtF,yHAAyH;IACzH,uBAAuB,CAAC,EAAE,OAAO,uBAAuB,CAAC;CAC1D;AAED;;;;;;;;;GASG;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;;;;;OAKG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC;IAE9B;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;GAKG;AAEH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,6BAA6B,GAAG,wBAAwB,GAAG;IAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,CAOhJ"}
1
+ {"version":3,"file":"CachingHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAMA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,8DAA8D;IAC9D,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,iEAAiE;IACjE,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,GAAG,kBAAkB,CAAC;IAEtF,yHAAyH;IACzH,uBAAuB,CAAC,EAAE,OAAO,uBAAuB,CAAC;CAC1D;AAED;;;;;;;;;GASG;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;;;;;OAKG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC;IAE9B;;;OAGG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;;GAKG;AAEH,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,6BAA6B,GACnC,wBAAwB,GAAG;IAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,CAO7D"}
@@ -11,7 +11,7 @@ import { createIModelHiliteSetProvider } from "./IModelHiliteSetProvider.js";
11
11
  * @public
12
12
  * @deprecated in 1.5. Use `createIModelHiliteSetProvider` instead.
13
13
  */
14
- /* c8 ignore start */
14
+ /* v8 ignore start */
15
15
  export function createCachingHiliteSetProvider(props) {
16
16
  const provider = createIModelHiliteSetProvider(props);
17
17
  return {
@@ -20,5 +20,5 @@ export function createCachingHiliteSetProvider(props) {
20
20
  dispose: () => provider[Symbol.dispose](),
21
21
  };
22
22
  }
23
- /* c8 ignore end */
23
+ /* v8 ignore stop */
24
24
  //# sourceMappingURL=CachingHiliteSetProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CachingHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,qDAAqD;AAErD,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAsD7E;;;;;GAKG;AACH,qBAAqB;AACrB,MAAM,UAAU,8BAA8B,CAAC,KAAoC;IACjF,MAAM,QAAQ,GAAG,6BAA6B,CAAC,KAAK,CAAC,CAAC;IACtD,OAAO;QACL,YAAY,EAAE,CAAC,cAAqC,EAAE,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,cAAc,CAAC;QACrG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QAClD,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;KAC1C,CAAC;AACJ,CAAC;AACD,mBAAmB","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/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport \"./DisposePolyfill.js\";\n\nimport { createIModelHiliteSetProvider } from \"./IModelHiliteSetProvider.js\";\n\nimport type { ECClassHierarchyInspector, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport type { createHiliteSetProvider, HiliteSet } from \"./HiliteSetProvider.js\";\nimport type { SelectionStorage } from \"./SelectionStorage.js\";\n\n/**\n * Props for creating a `CachingHiliteSetProvider` instance.\n * @public\n * @deprecated in 1.5. Use `IModelHiliteSetProviderProps` instead.\n */\nexport interface CachingHiliteSetProviderProps {\n /** Selection storage to use for retrieving the hilite set. */\n selectionStorage: SelectionStorage;\n\n /** A callback that should return iModel access by iModel key. */\n imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n\n /** An optional hilite set provider factory. If not provided, defaults to `createHiliteSetProvider` from this package. */\n createHiliteSetProvider?: typeof createHiliteSetProvider;\n}\n\n/**\n * Defines return value of `createCachingHiliteSetProvider`.\n *\n * **Warning:** 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 *\n * @see `createCachingHiliteSetProvider`\n * @public\n * @deprecated in 1.5. Use `IModelHiliteSetProvider` instead.\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 /**\n * Disposes the cache.\n *\n * Optional to avoid breaking the API. Will be made required when the deprecated\n * `dispose` is removed.\n */\n [Symbol.dispose]?: () => void;\n\n /**\n * Disposes the cache.\n * @deprecated in 1.2. Use `[Symbol.dispose]` instead.\n */\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 * @public\n * @deprecated in 1.5. Use `createIModelHiliteSetProvider` instead.\n */\n/* c8 ignore start */\nexport function createCachingHiliteSetProvider(props: CachingHiliteSetProviderProps): CachingHiliteSetProvider & { [Symbol.dispose]: () => void } {\n const provider = createIModelHiliteSetProvider(props);\n return {\n getHiliteSet: (hiliteSetProps: { imodelKey: string }) => provider.getCurrentHiliteSet(hiliteSetProps),\n [Symbol.dispose]: () => provider[Symbol.dispose](),\n dispose: () => provider[Symbol.dispose](),\n };\n}\n/* c8 ignore end */\n"]}
1
+ {"version":3,"file":"CachingHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/CachingHiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,qDAAqD;AAErD,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAsD7E;;;;;GAKG;AACH,qBAAqB;AACrB,MAAM,UAAU,8BAA8B,CAC5C,KAAoC;IAEpC,MAAM,QAAQ,GAAG,6BAA6B,CAAC,KAAK,CAAC,CAAC;IACtD,OAAO;QACL,YAAY,EAAE,CAAC,cAAqC,EAAE,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,cAAc,CAAC;QACrG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QAClD,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;KAC1C,CAAC;AACJ,CAAC;AACD,oBAAoB","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/* eslint-disable @typescript-eslint/no-deprecated */\n\nimport \"./DisposePolyfill.js\";\n\nimport { createIModelHiliteSetProvider } from \"./IModelHiliteSetProvider.js\";\n\nimport type { ECClassHierarchyInspector, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport type { createHiliteSetProvider, HiliteSet } from \"./HiliteSetProvider.js\";\nimport type { SelectionStorage } from \"./SelectionStorage.js\";\n\n/**\n * Props for creating a `CachingHiliteSetProvider` instance.\n * @public\n * @deprecated in 1.5. Use `IModelHiliteSetProviderProps` instead.\n */\nexport interface CachingHiliteSetProviderProps {\n /** Selection storage to use for retrieving the hilite set. */\n selectionStorage: SelectionStorage;\n\n /** A callback that should return iModel access by iModel key. */\n imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n\n /** An optional hilite set provider factory. If not provided, defaults to `createHiliteSetProvider` from this package. */\n createHiliteSetProvider?: typeof createHiliteSetProvider;\n}\n\n/**\n * Defines return value of `createCachingHiliteSetProvider`.\n *\n * **Warning:** 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 *\n * @see `createCachingHiliteSetProvider`\n * @public\n * @deprecated in 1.5. Use `IModelHiliteSetProvider` instead.\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 /**\n * Disposes the cache.\n *\n * Optional to avoid breaking the API. Will be made required when the deprecated\n * `dispose` is removed.\n */\n [Symbol.dispose]?: () => void;\n\n /**\n * Disposes the cache.\n * @deprecated in 1.2. Use `[Symbol.dispose]` instead.\n */\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 * @public\n * @deprecated in 1.5. Use `createIModelHiliteSetProvider` instead.\n */\n/* v8 ignore start */\nexport function createCachingHiliteSetProvider(\n props: CachingHiliteSetProviderProps,\n): CachingHiliteSetProvider & { [Symbol.dispose]: () => void } {\n const provider = createIModelHiliteSetProvider(props);\n return {\n getHiliteSet: (hiliteSetProps: { imodelKey: string }) => provider.getCurrentHiliteSet(hiliteSetProps),\n [Symbol.dispose]: () => provider[Symbol.dispose](),\n dispose: () => provider[Symbol.dispose](),\n };\n}\n/* v8 ignore stop */\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"EnableUnifiedSelectionSyncWithIModel.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/EnableUnifiedSelectionSyncWithIModel.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAY9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,sBAAsB,EAAkD,MAAM,mBAAmB,CAAC;AAErI;;;GAGG;AACH,MAAM,WAAW,yCAAyC;IACxD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,YAAY,EAAE,kBAAkB,GAC9B,yBAAyB,GAAG;QAC1B,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;;;OAGG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,uCAAuC;IACvC,mBAAmB,EAAE,MAAM,cAAc,CAAC;IAE1C;;;;;;;OAOG;IACH,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;IAElD;;;;;;;;;;;;;;OAcG;IAEH,wBAAwB,CAAC,EAAE,wBAAwB,GAAG,CAAC,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC,GAAG;QAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC,CAAC;CACtI;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,yCAAyC,GAAG,MAAM,IAAI,CAGjH;AAED;;;;;GAKG;AACH,qBAAa,sBAAsB;;IACjC,OAAO,CAAC,oBAAoB,CAAU;IAEtC,OAAO,CAAC,aAAa,CAA4D;IACjF,OAAO,CAAC,iBAAiB,CAAmB;IAC5C,OAAO,CAAC,wBAAwB,CAAoF;IACpH,OAAO,CAAC,oBAAoB,CAAuB;IAEnD,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,8BAA8B,CAAK;IAC3C,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,mCAAmC,CAAa;IACxD,OAAO,CAAC,qCAAqC,CAAa;IAC1D,OAAO,CAAC,iCAAiC,CAAa;gBAInC,KAAK,EAAE,yCAAyC,GAAG;QAAE,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;KAAE;IA4CxG,CAAC,MAAM,CAAC,OAAO,CAAC;IAOvB,4GAA4G;IACrG,8BAA8B;;;IAUrC,OAAO,CAAC,aAAa;IAuCrB,OAAO,CAAC,yBAAyB,CAa/B;IAEF,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,eAAe;IAuBvB,OAAO,CAAC,wBAAwB,CAsD9B;CACH"}
1
+ {"version":3,"file":"EnableUnifiedSelectionSyncWithIModel.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/EnableUnifiedSelectionSyncWithIModel.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAY9B,OAAO,KAAK,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAa,iBAAiB,EAAE,MAAM,wB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,CAAuB;IAEnD,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,8BAA8B,CAAK;IAC3C,OAAO,CAAC,qBAAqB,CAAuB;IACpD,OAAO,CAAC,mCAAmC,CAAa;IACxD,OAAO,CAAC,qCAAqC,CAAa;IAC1D,OAAO,CAAC,iCAAiC,CAAa;gBAInC,KAAK,EAAE,yCAAyC,GAAG;QAAE,iBAAiB,CAAC,EAAE,iBAAiB,CAAA;KAAE;IAoDxG,CAAC,MAAM,CAAC,OAAO,CAAC;IAOvB,4GAA4G;IACrG,8BAA8B;;;IAUrC,OAAO,CAAC,aAAa;IAmDrB,OAAO,CAAC,yBAAyB,CAa/B;IAEF,OAAO,CAAC,qBAAqB;IAwB7B,OAAO,CAAC,YAAY;IA2BpB,OAAO,CAAC,eAAe;IA0BvB,OAAO,CAAC,wBAAwB,CAwD9B;CACH"}
@@ -101,25 +101,25 @@ export class IModelSelectionHandler {
101
101
  if (props.imodelHiliteSetProvider) {
102
102
  return [props.imodelHiliteSetProvider, () => { }];
103
103
  }
104
- // eslint-disable-next-line @typescript-eslint/no-deprecated
104
+ /* eslint-disable @typescript-eslint/no-deprecated */
105
+ /* v8 ignore else -- @preserve */
105
106
  if (props.cachingHiliteSetProvider) {
106
107
  return [
107
- createIModelHiliteSetProviderFromCachingProvider(
108
- // eslint-disable-next-line @typescript-eslint/no-deprecated
109
- props.cachingHiliteSetProvider, props.hiliteSetProvider ?? createHiliteSetProvider({ imodelAccess: props.imodelAccess })),
108
+ createIModelHiliteSetProviderFromCachingProvider(props.cachingHiliteSetProvider, props.hiliteSetProvider ?? createHiliteSetProvider({ imodelAccess: props.imodelAccess })),
110
109
  // don't need to dispose anything, because our wrapper has no dispose logic, and `cachingHiliteSetProvider` should be disposed
111
110
  // by whoever owns it
112
111
  () => { },
113
112
  ];
114
113
  }
115
- /* c8 ignore start */
114
+ /* eslint-enable @typescript-eslint/no-deprecated */
115
+ /* v8 ignore start */
116
116
  const internalProvider = createIModelHiliteSetProvider({
117
117
  selectionStorage: this._selectionStorage,
118
118
  imodelProvider: () => this._imodelAccess,
119
119
  createHiliteSetProvider: () => props.hiliteSetProvider ?? createHiliteSetProvider({ imodelAccess: props.imodelAccess }),
120
120
  });
121
121
  return [internalProvider, () => safeDispose(internalProvider)];
122
- /* c8 ignore end */
122
+ /* v8 ignore stop */
123
123
  })();
124
124
  this._unregisterIModelSelectionSetListener = this._imodelAccess.selectionSet.onChanged.addListener(this.onIModelSelectionChanged);
125
125
  this._unregisterUnifiedSelectionListener = this._selectionStorage.selectionChangeEvent.addListener(this.onUnifiedSelectionChanged);
@@ -162,7 +162,9 @@ export class IModelSelectionHandler {
162
162
  "clearAll",
163
163
  });
164
164
  case "add":
165
- return void from(this._imodelHiliteSetProvider.getHiliteSetProvider({ imodelKey: this._imodelAccess.key }).getHiliteSet({ selectables }))
165
+ return void from(this._imodelHiliteSetProvider
166
+ .getHiliteSetProvider({ imodelKey: this._imodelAccess.key })
167
+ .getHiliteSet({ selectables }))
166
168
  .pipe(takeUntil(this._cancelOngoingChanges))
167
169
  .subscribe({
168
170
  next: (set) => {
@@ -170,7 +172,9 @@ export class IModelSelectionHandler {
170
172
  },
171
173
  });
172
174
  case "remove":
173
- return void from(this._imodelHiliteSetProvider.getHiliteSetProvider({ imodelKey: this._imodelAccess.key }).getHiliteSet({ selectables }))
175
+ return void from(this._imodelHiliteSetProvider
176
+ .getHiliteSetProvider({ imodelKey: this._imodelAccess.key })
177
+ .getHiliteSet({ selectables }))
174
178
  .pipe(takeUntil(this._cancelOngoingChanges))
175
179
  .subscribe({
176
180
  next: (set) => {
@@ -194,7 +198,7 @@ export class IModelSelectionHandler {
194
198
  }
195
199
  this.syncHiliteSet(args);
196
200
  };
197
- applyCurrentHiliteSet({ activeSelectionAction }) {
201
+ applyCurrentHiliteSet({ activeSelectionAction, }) {
198
202
  if (activeSelectionAction !== "keep") {
199
203
  const env_1 = { stack: [], error: void 0, hasError: false };
200
204
  try {
@@ -236,12 +240,15 @@ export class IModelSelectionHandler {
236
240
  }
237
241
  else {
238
242
  // pre-5.0 core requires adding models and subcategories to hilite set separately
243
+ /* v8 ignore else -- @preserve */
239
244
  if (set.models.length) {
240
245
  this._imodelAccess.hiliteSet.models.addIds(set.models);
241
246
  }
247
+ /* v8 ignore else -- @preserve */
242
248
  if (set.subCategories.length) {
243
249
  this._imodelAccess.hiliteSet.subcategories.addIds(set.subCategories);
244
250
  }
251
+ /* v8 ignore else -- @preserve */
245
252
  if (set.elements.length) {
246
253
  this._imodelAccess.hiliteSet.elements.addIds(set.elements);
247
254
  this._imodelAccess.selectionSet.add(set.elements);
@@ -269,12 +276,15 @@ export class IModelSelectionHandler {
269
276
  });
270
277
  }
271
278
  else {
279
+ /* v8 ignore else -- @preserve */
272
280
  if (set.models.length) {
273
281
  this._imodelAccess.hiliteSet.models.deleteIds(set.models);
274
282
  }
283
+ /* v8 ignore else -- @preserve */
275
284
  if (set.subCategories.length) {
276
285
  this._imodelAccess.hiliteSet.subcategories.deleteIds(set.subCategories);
277
286
  }
287
+ /* v8 ignore else -- @preserve */
278
288
  if (set.elements.length) {
279
289
  this._imodelAccess.hiliteSet.elements.deleteIds(set.elements);
280
290
  this._imodelAccess.selectionSet.remove(set.elements);
@@ -305,9 +315,11 @@ export class IModelSelectionHandler {
305
315
  scope: this._activeScopeProvider(),
306
316
  componentId: this.#componentId,
307
317
  }))
308
- : /* c8 ignore next */ EMPTY, ids.models ? from(ids.models).pipe(map((id) => ({ className: "BisCore.Model", id }))) : /* c8 ignore next */ EMPTY, ids.subcategories
318
+ : /* v8 ignore next */ EMPTY, ids.models
319
+ ? from(ids.models).pipe(map((id) => ({ className: "BisCore.Model", id })))
320
+ : /* v8 ignore next */ EMPTY, ids.subcategories
309
321
  ? from(ids.subcategories).pipe(map((id) => ({ className: "BisCore.SubCategory", id })))
310
- : /* c8 ignore next */ EMPTY);
322
+ : /* v8 ignore next */ EMPTY);
311
323
  const selectionStorageVersion = this._selectionStorageChangeTracker;
312
324
  const changeSelectionStorageProps = {
313
325
  imodelKey: this._imodelAccess.key,
@@ -340,9 +352,9 @@ export class IModelSelectionHandler {
340
352
  function getSelectionSetChangeIds(event) {
341
353
  switch (event.type) {
342
354
  case CoreSelectionSetEventType.Add:
343
- return event.additions ?? (event.added ? { elements: event.added } : /* c8 ignore next */ {});
355
+ return event.additions ?? (event.added ? { elements: event.added } : /* v8 ignore next */ {});
344
356
  case CoreSelectionSetEventType.Remove:
345
- return event.removals ?? (event.removed ? { elements: event.removed } : /* c8 ignore next */ {});
357
+ return event.removals ?? (event.removed ? { elements: event.removed } : /* v8 ignore next */ {});
346
358
  case CoreSelectionSetEventType.Replace:
347
359
  return "active" in event.set ? event.set.active : { elements: event.set.elements };
348
360
  }
@@ -355,6 +367,7 @@ function getUnifiedSelectionChangeType(coreChangeType) {
355
367
  return "remove";
356
368
  case CoreSelectionSetEventType.Replace:
357
369
  return "replace";
370
+ /* v8 ignore next -- @preserve */
358
371
  case CoreSelectionSetEventType.Clear:
359
372
  return "clear";
360
373
  }
@@ -362,7 +375,7 @@ function getUnifiedSelectionChangeType(coreChangeType) {
362
375
  function is5xSelectionSet(selectionSet) {
363
376
  return "active" in selectionSet;
364
377
  }
365
- /* c8 ignore start */
378
+ /* v8 ignore start */
366
379
  function createIModelHiliteSetProviderFromCachingProvider(cachingHiliteSetProvider, hiliteSetProvider) {
367
380
  return {
368
381
  getHiliteSetProvider: () => hiliteSetProvider,
@@ -370,5 +383,5 @@ function createIModelHiliteSetProviderFromCachingProvider(cachingHiliteSetProvid
370
383
  [Symbol.dispose]: () => { },
371
384
  };
372
385
  }
373
- /* c8 ignore end */
386
+ /* v8 ignore stop */
374
387
  //# sourceMappingURL=EnableUnifiedSelectionSyncWithIModel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnableUnifiedSelectionSyncWithIModel.js","sourceRoot":"","sources":["../../../src/unified-selection/EnableUnifiedSelectionSyncWithIModel.ts"],"names":[],"mappings":"AAAA;;;gGAGgG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AAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IACvF,CAAC;AACH,CAAC;AAED,SAAS,6BAA6B,CAAC,cAAyC;IAC9E,QAAQ,cAAc,EAAE,CAAC;QACvB,KAAK,yBAAyB,CAAC,GAAG;YAChC,OAAO,KAAK,CAAC;QACf,KAAK,yBAAyB,CAAC,MAAM;YACnC,OAAO,QAAQ,CAAC;QAClB,KAAK,yBAAyB,CAAC,OAAO;YACpC,OAAO,SAAS,CAAC;QACnB,KAAK,yBAAyB,CAAC,KAAK;YAClC,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,YAAoC;IAK5D,OAAO,QAAQ,IAAI,YAAY,CAAC;AAClC,CAAC;AAED,qBAAqB;AACrB,SAAS,gDAAgD,CACvD,wBAA4G,EAC5G,iBAAoC;IAEpC,OAAO;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC,iBAAiB;QAC7C,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,YAAY,CAAC,KAAK,CAAC;QAC5E,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAE,CAAC;KAC3B,CAAC;AACJ,CAAC;AACD,mBAAmB","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 \"./DisposePolyfill.js\";\n\nimport { EMPTY, firstValueFrom, from, map, merge, Subject, takeUntil, toArray } from \"rxjs\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { createHiliteSetProvider } from \"./HiliteSetProvider.js\";\nimport { createIModelHiliteSetProvider } from \"./IModelHiliteSetProvider.js\";\nimport { Selectables } from \"./Selectable.js\";\nimport { computeSelection } from \"./SelectionScope.js\";\nimport { CoreSelectionSetEventType } from \"./types/IModel.js\";\nimport { safeDispose } from \"./Utils.js\";\n\nimport type { GuidString, Id64Arg, Id64Set } from \"@itwin/core-bentley\";\nimport type { ECClassHierarchyInspector, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport type { CachingHiliteSetProvider } from \"./CachingHiliteSetProvider.js\";\nimport type { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider.js\";\nimport type { IModelHiliteSetProvider } from \"./IModelHiliteSetProvider.js\";\nimport type { SelectableInstanceKey } from \"./Selectable.js\";\nimport type { StorageSelectionChangeEventArgs, StorageSelectionChangeType } from \"./SelectionChangeEvent.js\";\nimport type { SelectionScope } from \"./SelectionScope.js\";\nimport type { SelectionStorage } from \"./SelectionStorage.js\";\nimport type { CoreIModelHiliteSet, CoreIModelSelectionSet, CoreSelectableIds, CoreSelectionSetEventUnsafe } from \"./types/IModel.js\";\n\n/**\n * Props for `enableUnifiedSelectionSyncWithIModel`.\n * @public\n */\nexport interface EnableUnifiedSelectionSyncWithIModelProps {\n /**\n * Provides access to different iModel's features: query executing, class hierarchy, selection and hilite sets.\n *\n * It's recommended to use `@itwin/presentation-core-interop` to create `key`, `ECSqlQueryExecutor` and `ECSchemaProvider` from\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/), and map its\n * `hilited` and `selectionSet` attributes like this:\n *\n * ```ts\n * import { createECSqlQueryExecutor, createECSchemaProvider, createIModelKey } from \"@itwin/presentation-core-interop\";\n * import { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\n * import { IModelConnection } from \"@itwin/core-frontend\";\n *\n * const imodel: IModelConnection = ...\n * const imodelAccess = {\n * ...createECSqlQueryExecutor(imodel),\n * ...createCachingECClassHierarchyInspector({ schemaProvider: createECSchemaProvider(MyAppFrontend.getSchemaContext(imodel)) }),\n * key: createIModelKey(imodel),\n * hiliteSet: imodel.hilited,\n * selectionSet: imodel.selectionSet,\n * };\n * ```\n */\n imodelAccess: ECSqlQueryExecutor &\n ECClassHierarchyInspector & {\n /** Key of the iModel. Generally taken from `IModelConnection.key`. */\n readonly key: string;\n /** The set of currently hilited elements taken from `IModelConnection.hilited`. */\n readonly hiliteSet: CoreIModelHiliteSet;\n /** The set of currently selected elements taken from `IModelConnection.selectionSet`. */\n readonly selectionSet: CoreIModelSelectionSet;\n };\n\n /**\n * Unified selection storage to synchronize IModel's tool selection with. The storage should be shared\n * across all components in the application to ensure unified selection experience.\n */\n selectionStorage: SelectionStorage;\n\n /** Active selection scope provider. */\n activeScopeProvider: () => SelectionScope;\n\n /**\n * An iModel hilite set provider used to retrieve hilite sets for different iModels. If not provided, a new `IModelHiliteSetProvider`\n * will be created for the given iModel using the provided `imodelAccess`.\n * If the consuming application already has a `IModelHiliteSetProvider` defined, it should be provided instead\n * to reuse the cache and avoid creating new providers for each iModel.\n *\n * @see `createIModelHiliteSetProvider`\n */\n imodelHiliteSetProvider?: IModelHiliteSetProvider;\n\n /**\n * A caching hilite set provider used to retrieve hilite sets for an iModel. If not provided, a new `CachingHiliteSetProvider`\n * will be created for the given iModel using the provided `imodelAccess`.\n * If the consuming application already has a `CachingHiliteSetProvider` defined, it should be provided instead\n * to reuse the cache and avoid creating new providers for each iModel.\n *\n * The type is defined in a way that makes it required for provider to have either the deprecated `dispose` or the\n * new `Symbol.dispose` method.\n *\n * **Warning:** When the given `CachingHiliteSetProvider` internally uses a custom `HiliteSetProvider`, the synchronization has\n * no access to it, and thus uses its own, default, `HiliteSetProvider`. As a result, the synchronization may not work as expected.\n * To alleviate this, the `imodelHiliteSetProvider` prop should be used instead.\n *\n * @deprecated in 1.5. Use `imodelHiliteSetProvider` prop instead.\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n cachingHiliteSetProvider?: CachingHiliteSetProvider | (Omit<CachingHiliteSetProvider, \"dispose\"> & { [Symbol.dispose]: () => void });\n}\n\n/**\n * Enables synchronization between iModel selection and unified selection.\n * @returns function for disposing the synchronization.\n * @public\n */\nexport function enableUnifiedSelectionSyncWithIModel(props: EnableUnifiedSelectionSyncWithIModelProps): () => void {\n const selectionHandler = new IModelSelectionHandler(props);\n return () => selectionHandler[Symbol.dispose]();\n}\n\n/**\n * A handler that syncs selection between unified selection storage (`SelectionStorage`) and\n * an iModel (`iModel.selectionSet`, `iModel.hilited`).\n *\n * @internal\n */\nexport class IModelSelectionHandler {\n private _selectionSourceName = \"Tool\";\n\n private _imodelAccess: EnableUnifiedSelectionSyncWithIModelProps[\"imodelAccess\"];\n private _selectionStorage: SelectionStorage;\n private _imodelHiliteSetProvider: NonNullable<EnableUnifiedSelectionSyncWithIModelProps[\"imodelHiliteSetProvider\"]>;\n private _activeScopeProvider: () => SelectionScope;\n\n private _isSuspended: boolean;\n private _selectionStorageChangeTracker = 0;\n private _cancelOngoingChanges = new Subject<void>();\n private _unregisterUnifiedSelectionListener: () => void;\n private _unregisterIModelSelectionSetListener: () => void;\n private _disposeInternalHiliteSetProvider: () => void;\n\n #componentId: GuidString;\n\n public constructor(props: EnableUnifiedSelectionSyncWithIModelProps & { hiliteSetProvider?: HiliteSetProvider }) {\n this.#componentId = Guid.createValue();\n this._imodelAccess = props.imodelAccess;\n this._selectionStorage = props.selectionStorage;\n this._activeScopeProvider = props.activeScopeProvider;\n this._isSuspended = false;\n [this._imodelHiliteSetProvider, this._disposeInternalHiliteSetProvider] = (() => {\n if (props.imodelHiliteSetProvider) {\n return [props.imodelHiliteSetProvider, () => {}];\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (props.cachingHiliteSetProvider) {\n return [\n createIModelHiliteSetProviderFromCachingProvider(\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n props.cachingHiliteSetProvider,\n props.hiliteSetProvider ?? createHiliteSetProvider({ imodelAccess: props.imodelAccess }),\n ),\n // don't need to dispose anything, because our wrapper has no dispose logic, and `cachingHiliteSetProvider` should be disposed\n // by whoever owns it\n () => {},\n ];\n }\n /* c8 ignore start */\n const internalProvider = createIModelHiliteSetProvider({\n selectionStorage: this._selectionStorage,\n imodelProvider: () => this._imodelAccess,\n createHiliteSetProvider: () => props.hiliteSetProvider ?? createHiliteSetProvider({ imodelAccess: props.imodelAccess }),\n });\n return [internalProvider, () => safeDispose(internalProvider)];\n /* c8 ignore end */\n })();\n\n this._unregisterIModelSelectionSetListener = this._imodelAccess.selectionSet.onChanged.addListener(this.onIModelSelectionChanged);\n this._unregisterUnifiedSelectionListener = this._selectionStorage.selectionChangeEvent.addListener(this.onUnifiedSelectionChanged);\n\n if (!is5xSelectionSet(this._imodelAccess.selectionSet)) {\n // itwinjs-core@4: stop imodel from syncing tool selection with hilited list - we want to manage that sync ourselves\n this._imodelAccess.hiliteSet.wantSyncWithSelectionSet = false;\n }\n\n this.applyCurrentHiliteSet({ activeSelectionAction: \"clearAll\" });\n }\n\n public [Symbol.dispose]() {\n this._cancelOngoingChanges.next();\n this._unregisterIModelSelectionSetListener();\n this._unregisterUnifiedSelectionListener();\n this._disposeInternalHiliteSetProvider();\n }\n\n /** Temporarily suspends tool selection synchronization until the returned disposable object is disposed. */\n public suspendIModelToolSelectionSync() {\n const wasSuspended = this._isSuspended;\n this._isSuspended = true;\n return {\n [Symbol.dispose]: () => {\n this._isSuspended = wasSuspended;\n },\n };\n }\n\n private syncHiliteSet(props: { changeType: StorageSelectionChangeType; selectables: Selectables; source: string }): void {\n const { changeType, selectables, source } = props;\n switch (changeType) {\n case \"clear\":\n return this.applyCurrentHiliteSet({ activeSelectionAction: \"clearAll\" });\n case \"replace\":\n return this.applyCurrentHiliteSet({\n activeSelectionAction:\n source === this._selectionSourceName\n ? is5xSelectionSet(this._imodelAccess.selectionSet)\n ? // with 5x core we don't need to clear anything when event is triggered by a Tool (hilite and selection sets are in sync already)\n \"keep\"\n : // with 4x core we need to clear hilite set, because it's not synced with selection set\n \"clearHilited\"\n : // when event is triggered not by a Tool, we need to clear everything\n \"clearAll\",\n });\n case \"add\":\n return void from(this._imodelHiliteSetProvider.getHiliteSetProvider({ imodelKey: this._imodelAccess.key }).getHiliteSet({ selectables }))\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (set) => {\n this.addHiliteSet(set);\n },\n });\n case \"remove\":\n return void from(this._imodelHiliteSetProvider.getHiliteSetProvider({ imodelKey: this._imodelAccess.key }).getHiliteSet({ selectables }))\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (set) => {\n this.removeHiliteSet(set);\n },\n complete: () => {\n this.applyCurrentHiliteSet({ activeSelectionAction: \"keep\" });\n },\n });\n }\n }\n\n private onUnifiedSelectionChanged = (args: StorageSelectionChangeEventArgs) => {\n // iModels are only interested in top-level selection changes\n if (args.imodelKey !== this._imodelAccess.key || args.level !== 0) {\n return;\n }\n\n // update the selection storage change tracker so we know the selection storage changed\n this._selectionStorageChangeTracker = (this._selectionStorageChangeTracker + 1) % Number.MAX_SAFE_INTEGER;\n\n if (args.changeType === \"replace\" || args.changeType === \"clear\") {\n this._cancelOngoingChanges.next();\n }\n this.syncHiliteSet(args);\n };\n\n private applyCurrentHiliteSet({ activeSelectionAction }: { activeSelectionAction: \"clearAll\" | \"clearHilited\" | \"keep\" }) {\n if (activeSelectionAction !== \"keep\") {\n using _dispose = this.suspendIModelToolSelectionSync();\n if (!is5xSelectionSet(this._imodelAccess.selectionSet)) {\n this._imodelAccess.hiliteSet.clear();\n }\n if (activeSelectionAction === \"clearAll\") {\n this._imodelAccess.selectionSet.emptyAll();\n }\n }\n\n from(this._imodelHiliteSetProvider.getCurrentHiliteSet({ imodelKey: this._imodelAccess.key }))\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (ids) => {\n this.addHiliteSet(ids);\n },\n });\n }\n\n private addHiliteSet(set: HiliteSet) {\n using _dispose = this.suspendIModelToolSelectionSync();\n if (is5xSelectionSet(this._imodelAccess.selectionSet)) {\n // with 5.x core we can simply add the set as a whole\n this._imodelAccess.selectionSet.add({\n models: set.models,\n subcategories: set.subCategories,\n elements: set.elements,\n });\n } else {\n // pre-5.0 core requires adding models and subcategories to hilite set separately\n if (set.models.length) {\n this._imodelAccess.hiliteSet.models.addIds(set.models);\n }\n if (set.subCategories.length) {\n this._imodelAccess.hiliteSet.subcategories.addIds(set.subCategories);\n }\n if (set.elements.length) {\n this._imodelAccess.hiliteSet.elements.addIds(set.elements);\n this._imodelAccess.selectionSet.add(set.elements);\n }\n }\n }\n\n private removeHiliteSet(set: HiliteSet) {\n using _dispose = this.suspendIModelToolSelectionSync();\n if (is5xSelectionSet(this._imodelAccess.selectionSet)) {\n // with 5.x core we can simply remove the set as a whole\n this._imodelAccess.selectionSet.remove({\n models: set.models,\n subcategories: set.subCategories,\n elements: set.elements,\n });\n } else {\n if (set.models.length) {\n this._imodelAccess.hiliteSet.models.deleteIds(set.models);\n }\n if (set.subCategories.length) {\n this._imodelAccess.hiliteSet.subcategories.deleteIds(set.subCategories);\n }\n if (set.elements.length) {\n this._imodelAccess.hiliteSet.elements.deleteIds(set.elements);\n this._imodelAccess.selectionSet.remove(set.elements);\n }\n }\n }\n\n private onIModelSelectionChanged = async (event: CoreSelectionSetEventUnsafe): Promise<void> => {\n if (this._isSuspended) {\n return;\n }\n\n if (CoreSelectionSetEventType.Clear === event.type) {\n this._selectionStorage.clearSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName });\n return;\n }\n\n const ids = getSelectionSetChangeIds(event);\n const scopedSelection = merge(\n ids.elements\n ? from(\n computeSelection({\n queryExecutor: this._imodelAccess,\n elementIds: ids.elements,\n scope: this._activeScopeProvider(),\n componentId: this.#componentId,\n }),\n )\n : /* c8 ignore next */ EMPTY,\n ids.models ? from(ids.models).pipe(map((id): SelectableInstanceKey => ({ className: \"BisCore.Model\", id }))) : /* c8 ignore next */ EMPTY,\n ids.subcategories\n ? from(ids.subcategories).pipe(map((id): SelectableInstanceKey => ({ className: \"BisCore.SubCategory\", id })))\n : /* c8 ignore next */ EMPTY,\n );\n\n const selectionStorageVersion = this._selectionStorageChangeTracker;\n const changeSelectionStorageProps = {\n imodelKey: this._imodelAccess.key,\n source: this._selectionSourceName,\n selectables: await firstValueFrom(scopedSelection.pipe(toArray())),\n };\n try {\n switch (event.type) {\n case CoreSelectionSetEventType.Add:\n return this._selectionStorage.addToSelection(changeSelectionStorageProps);\n case CoreSelectionSetEventType.Remove:\n return this._selectionStorage.removeFromSelection(changeSelectionStorageProps);\n case CoreSelectionSetEventType.Replace:\n return this._selectionStorage.replaceSelection(changeSelectionStorageProps);\n }\n } finally {\n if (this._selectionStorageChangeTracker === selectionStorageVersion) {\n // if the storage wasn't changed while we were processing the selection change, we have to re-sync the\n // hilite set (otherwise it's done by the selection storage change handler)\n this.syncHiliteSet({\n ...changeSelectionStorageProps,\n selectables: Selectables.create(changeSelectionStorageProps.selectables),\n changeType: getUnifiedSelectionChangeType(event.type),\n });\n }\n }\n };\n}\n\nfunction getSelectionSetChangeIds(\n event: Omit<CoreSelectionSetEventUnsafe, \"type\"> & {\n type: CoreSelectionSetEventType.Add | CoreSelectionSetEventType.Remove | CoreSelectionSetEventType.Replace;\n },\n): CoreSelectableIds {\n switch (event.type) {\n case CoreSelectionSetEventType.Add:\n return event.additions ?? (event.added ? { elements: event.added } : /* c8 ignore next */ {});\n case CoreSelectionSetEventType.Remove:\n return event.removals ?? (event.removed ? { elements: event.removed } : /* c8 ignore next */ {});\n case CoreSelectionSetEventType.Replace:\n return \"active\" in event.set ? event.set.active : { elements: event.set.elements };\n }\n}\n\nfunction getUnifiedSelectionChangeType(coreChangeType: CoreSelectionSetEventType): StorageSelectionChangeType {\n switch (coreChangeType) {\n case CoreSelectionSetEventType.Add:\n return \"add\";\n case CoreSelectionSetEventType.Remove:\n return \"remove\";\n case CoreSelectionSetEventType.Replace:\n return \"replace\";\n case CoreSelectionSetEventType.Clear:\n return \"clear\";\n }\n}\n\nfunction is5xSelectionSet(selectionSet: CoreIModelSelectionSet): selectionSet is Omit<CoreIModelSelectionSet, \"add\" | \"remove\"> & {\n readonly active: { [P in keyof CoreSelectableIds]-?: Id64Set };\n add: (ids: Id64Arg | CoreSelectableIds) => boolean;\n remove: (ids: Id64Arg | CoreSelectableIds) => boolean;\n} {\n return \"active\" in selectionSet;\n}\n\n/* c8 ignore start */\nfunction createIModelHiliteSetProviderFromCachingProvider(\n cachingHiliteSetProvider: NonNullable<EnableUnifiedSelectionSyncWithIModelProps[\"cachingHiliteSetProvider\"]>,\n hiliteSetProvider: HiliteSetProvider,\n): IModelHiliteSetProvider {\n return {\n getHiliteSetProvider: () => hiliteSetProvider,\n getCurrentHiliteSet: (props) => cachingHiliteSetProvider.getHiliteSet(props),\n [Symbol.dispose]: () => {},\n };\n}\n/* c8 ignore end */\n"]}
1
+ {"version":3,"file":"EnableUnifiedSelectionSyncWithIModel.js","sourceRoot":"","sources":["../../../src/unified-selection/EnableUnifiedSelectionSyncWithIModel.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhG,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC5F,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAgGzC;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAAC,KAAgD;IACnG,MAAM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AAClC,CAAC;AAED,qBAAqB;AACrB,SAAS,gDAAgD,CACvD,wBAA4G,EAC5G,iBAAoC;IAEpC,OAAO;QACL,oBAAoB,EAAE,GAAG,EAAE,CAAC,iBAAiB;QAC7C,mBAAmB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,CAAC,YAAY,CAAC,KAAK,CAAC;QAC5E,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,GAAE,CAAC;KAC3B,CAAC;AACJ,CAAC;AACD,oBAAoB","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 \"./DisposePolyfill.js\";\n\nimport { EMPTY, firstValueFrom, from, map, merge, Subject, takeUntil, toArray } from \"rxjs\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { createHiliteSetProvider } from \"./HiliteSetProvider.js\";\nimport { createIModelHiliteSetProvider } from \"./IModelHiliteSetProvider.js\";\nimport { Selectables } from \"./Selectable.js\";\nimport { computeSelection } from \"./SelectionScope.js\";\nimport { CoreSelectionSetEventType } from \"./types/IModel.js\";\nimport { safeDispose } from \"./Utils.js\";\n\nimport type { GuidString, Id64Arg, Id64Set } from \"@itwin/core-bentley\";\nimport type { ECClassHierarchyInspector, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport type { CachingHiliteSetProvider } from \"./CachingHiliteSetProvider.js\";\nimport type { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider.js\";\nimport type { IModelHiliteSetProvider } from \"./IModelHiliteSetProvider.js\";\nimport type { SelectableInstanceKey } from \"./Selectable.js\";\nimport type { StorageSelectionChangeEventArgs, StorageSelectionChangeType } from \"./SelectionChangeEvent.js\";\nimport type { SelectionScope } from \"./SelectionScope.js\";\nimport type { SelectionStorage } from \"./SelectionStorage.js\";\nimport type {\n CoreIModelHiliteSet,\n CoreIModelSelectionSet,\n CoreSelectableIds,\n CoreSelectionSetEventUnsafe,\n} from \"./types/IModel.js\";\n\n/**\n * Props for `enableUnifiedSelectionSyncWithIModel`.\n * @public\n */\nexport interface EnableUnifiedSelectionSyncWithIModelProps {\n /**\n * Provides access to different iModel's features: query executing, class hierarchy, selection and hilite sets.\n *\n * It's recommended to use `@itwin/presentation-core-interop` to create `key`, `ECSqlQueryExecutor` and `ECSchemaProvider` from\n * [IModelConnection](https://www.itwinjs.org/reference/core-frontend/imodelconnection/imodelconnection/), and map its\n * `hilited` and `selectionSet` attributes like this:\n *\n * ```ts\n * import { createECSqlQueryExecutor, createECSchemaProvider, createIModelKey } from \"@itwin/presentation-core-interop\";\n * import { createCachingECClassHierarchyInspector } from \"@itwin/presentation-shared\";\n * import { IModelConnection } from \"@itwin/core-frontend\";\n *\n * const imodel: IModelConnection = ...\n * const imodelAccess = {\n * ...createECSqlQueryExecutor(imodel),\n * ...createCachingECClassHierarchyInspector({ schemaProvider: createECSchemaProvider(MyAppFrontend.getSchemaContext(imodel)) }),\n * key: createIModelKey(imodel),\n * hiliteSet: imodel.hilited,\n * selectionSet: imodel.selectionSet,\n * };\n * ```\n */\n imodelAccess: ECSqlQueryExecutor &\n ECClassHierarchyInspector & {\n /** Key of the iModel. Generally taken from `IModelConnection.key`. */\n readonly key: string;\n /** The set of currently hilited elements taken from `IModelConnection.hilited`. */\n readonly hiliteSet: CoreIModelHiliteSet;\n /** The set of currently selected elements taken from `IModelConnection.selectionSet`. */\n readonly selectionSet: CoreIModelSelectionSet;\n };\n\n /**\n * Unified selection storage to synchronize IModel's tool selection with. The storage should be shared\n * across all components in the application to ensure unified selection experience.\n */\n selectionStorage: SelectionStorage;\n\n /** Active selection scope provider. */\n activeScopeProvider: () => SelectionScope;\n\n /**\n * An iModel hilite set provider used to retrieve hilite sets for different iModels. If not provided, a new `IModelHiliteSetProvider`\n * will be created for the given iModel using the provided `imodelAccess`.\n * If the consuming application already has a `IModelHiliteSetProvider` defined, it should be provided instead\n * to reuse the cache and avoid creating new providers for each iModel.\n *\n * @see `createIModelHiliteSetProvider`\n */\n imodelHiliteSetProvider?: IModelHiliteSetProvider;\n\n /**\n * A caching hilite set provider used to retrieve hilite sets for an iModel. If not provided, a new `CachingHiliteSetProvider`\n * will be created for the given iModel using the provided `imodelAccess`.\n * If the consuming application already has a `CachingHiliteSetProvider` defined, it should be provided instead\n * to reuse the cache and avoid creating new providers for each iModel.\n *\n * The type is defined in a way that makes it required for provider to have either the deprecated `dispose` or the\n * new `Symbol.dispose` method.\n *\n * **Warning:** When the given `CachingHiliteSetProvider` internally uses a custom `HiliteSetProvider`, the synchronization has\n * no access to it, and thus uses its own, default, `HiliteSetProvider`. As a result, the synchronization may not work as expected.\n * To alleviate this, the `imodelHiliteSetProvider` prop should be used instead.\n *\n * @deprecated in 1.5. Use `imodelHiliteSetProvider` prop instead.\n */\n cachingHiliteSetProvider?:\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n | CachingHiliteSetProvider\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n | (Omit<CachingHiliteSetProvider, \"dispose\"> & { [Symbol.dispose]: () => void });\n}\n\n/**\n * Enables synchronization between iModel selection and unified selection.\n * @returns function for disposing the synchronization.\n * @public\n */\nexport function enableUnifiedSelectionSyncWithIModel(props: EnableUnifiedSelectionSyncWithIModelProps): () => void {\n const selectionHandler = new IModelSelectionHandler(props);\n return () => selectionHandler[Symbol.dispose]();\n}\n\n/**\n * A handler that syncs selection between unified selection storage (`SelectionStorage`) and\n * an iModel (`iModel.selectionSet`, `iModel.hilited`).\n *\n * @internal\n */\nexport class IModelSelectionHandler {\n private _selectionSourceName = \"Tool\";\n\n private _imodelAccess: EnableUnifiedSelectionSyncWithIModelProps[\"imodelAccess\"];\n private _selectionStorage: SelectionStorage;\n private _imodelHiliteSetProvider: NonNullable<EnableUnifiedSelectionSyncWithIModelProps[\"imodelHiliteSetProvider\"]>;\n private _activeScopeProvider: () => SelectionScope;\n\n private _isSuspended: boolean;\n private _selectionStorageChangeTracker = 0;\n private _cancelOngoingChanges = new Subject<void>();\n private _unregisterUnifiedSelectionListener: () => void;\n private _unregisterIModelSelectionSetListener: () => void;\n private _disposeInternalHiliteSetProvider: () => void;\n\n #componentId: GuidString;\n\n public constructor(props: EnableUnifiedSelectionSyncWithIModelProps & { hiliteSetProvider?: HiliteSetProvider }) {\n this.#componentId = Guid.createValue();\n this._imodelAccess = props.imodelAccess;\n this._selectionStorage = props.selectionStorage;\n this._activeScopeProvider = props.activeScopeProvider;\n this._isSuspended = false;\n [this._imodelHiliteSetProvider, this._disposeInternalHiliteSetProvider] = (() => {\n if (props.imodelHiliteSetProvider) {\n return [props.imodelHiliteSetProvider, () => {}];\n }\n\n /* eslint-disable @typescript-eslint/no-deprecated */\n /* v8 ignore else -- @preserve */\n if (props.cachingHiliteSetProvider) {\n return [\n createIModelHiliteSetProviderFromCachingProvider(\n props.cachingHiliteSetProvider,\n props.hiliteSetProvider ?? createHiliteSetProvider({ imodelAccess: props.imodelAccess }),\n ),\n // don't need to dispose anything, because our wrapper has no dispose logic, and `cachingHiliteSetProvider` should be disposed\n // by whoever owns it\n () => {},\n ];\n }\n /* eslint-enable @typescript-eslint/no-deprecated */\n\n /* v8 ignore start */\n const internalProvider = createIModelHiliteSetProvider({\n selectionStorage: this._selectionStorage,\n imodelProvider: () => this._imodelAccess,\n createHiliteSetProvider: () =>\n props.hiliteSetProvider ?? createHiliteSetProvider({ imodelAccess: props.imodelAccess }),\n });\n return [internalProvider, () => safeDispose(internalProvider)];\n /* v8 ignore stop */\n })();\n\n this._unregisterIModelSelectionSetListener = this._imodelAccess.selectionSet.onChanged.addListener(\n this.onIModelSelectionChanged,\n );\n this._unregisterUnifiedSelectionListener = this._selectionStorage.selectionChangeEvent.addListener(\n this.onUnifiedSelectionChanged,\n );\n\n if (!is5xSelectionSet(this._imodelAccess.selectionSet)) {\n // itwinjs-core@4: stop imodel from syncing tool selection with hilited list - we want to manage that sync ourselves\n this._imodelAccess.hiliteSet.wantSyncWithSelectionSet = false;\n }\n\n this.applyCurrentHiliteSet({ activeSelectionAction: \"clearAll\" });\n }\n\n public [Symbol.dispose]() {\n this._cancelOngoingChanges.next();\n this._unregisterIModelSelectionSetListener();\n this._unregisterUnifiedSelectionListener();\n this._disposeInternalHiliteSetProvider();\n }\n\n /** Temporarily suspends tool selection synchronization until the returned disposable object is disposed. */\n public suspendIModelToolSelectionSync() {\n const wasSuspended = this._isSuspended;\n this._isSuspended = true;\n return {\n [Symbol.dispose]: () => {\n this._isSuspended = wasSuspended;\n },\n };\n }\n\n private syncHiliteSet(props: {\n changeType: StorageSelectionChangeType;\n selectables: Selectables;\n source: string;\n }): void {\n const { changeType, selectables, source } = props;\n switch (changeType) {\n case \"clear\":\n return this.applyCurrentHiliteSet({ activeSelectionAction: \"clearAll\" });\n case \"replace\":\n return this.applyCurrentHiliteSet({\n activeSelectionAction:\n source === this._selectionSourceName\n ? is5xSelectionSet(this._imodelAccess.selectionSet)\n ? // with 5x core we don't need to clear anything when event is triggered by a Tool (hilite and selection sets are in sync already)\n \"keep\"\n : // with 4x core we need to clear hilite set, because it's not synced with selection set\n \"clearHilited\"\n : // when event is triggered not by a Tool, we need to clear everything\n \"clearAll\",\n });\n case \"add\":\n return void from(\n this._imodelHiliteSetProvider\n .getHiliteSetProvider({ imodelKey: this._imodelAccess.key })\n .getHiliteSet({ selectables }),\n )\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (set) => {\n this.addHiliteSet(set);\n },\n });\n case \"remove\":\n return void from(\n this._imodelHiliteSetProvider\n .getHiliteSetProvider({ imodelKey: this._imodelAccess.key })\n .getHiliteSet({ selectables }),\n )\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (set) => {\n this.removeHiliteSet(set);\n },\n complete: () => {\n this.applyCurrentHiliteSet({ activeSelectionAction: \"keep\" });\n },\n });\n }\n }\n\n private onUnifiedSelectionChanged = (args: StorageSelectionChangeEventArgs) => {\n // iModels are only interested in top-level selection changes\n if (args.imodelKey !== this._imodelAccess.key || args.level !== 0) {\n return;\n }\n\n // update the selection storage change tracker so we know the selection storage changed\n this._selectionStorageChangeTracker = (this._selectionStorageChangeTracker + 1) % Number.MAX_SAFE_INTEGER;\n\n if (args.changeType === \"replace\" || args.changeType === \"clear\") {\n this._cancelOngoingChanges.next();\n }\n this.syncHiliteSet(args);\n };\n\n private applyCurrentHiliteSet({\n activeSelectionAction,\n }: {\n activeSelectionAction: \"clearAll\" | \"clearHilited\" | \"keep\";\n }) {\n if (activeSelectionAction !== \"keep\") {\n using _dispose = this.suspendIModelToolSelectionSync();\n if (!is5xSelectionSet(this._imodelAccess.selectionSet)) {\n this._imodelAccess.hiliteSet.clear();\n }\n if (activeSelectionAction === \"clearAll\") {\n this._imodelAccess.selectionSet.emptyAll();\n }\n }\n\n from(this._imodelHiliteSetProvider.getCurrentHiliteSet({ imodelKey: this._imodelAccess.key }))\n .pipe(takeUntil(this._cancelOngoingChanges))\n .subscribe({\n next: (ids) => {\n this.addHiliteSet(ids);\n },\n });\n }\n\n private addHiliteSet(set: HiliteSet) {\n using _dispose = this.suspendIModelToolSelectionSync();\n if (is5xSelectionSet(this._imodelAccess.selectionSet)) {\n // with 5.x core we can simply add the set as a whole\n this._imodelAccess.selectionSet.add({\n models: set.models,\n subcategories: set.subCategories,\n elements: set.elements,\n });\n } else {\n // pre-5.0 core requires adding models and subcategories to hilite set separately\n /* v8 ignore else -- @preserve */\n if (set.models.length) {\n this._imodelAccess.hiliteSet.models.addIds(set.models);\n }\n /* v8 ignore else -- @preserve */\n if (set.subCategories.length) {\n this._imodelAccess.hiliteSet.subcategories.addIds(set.subCategories);\n }\n /* v8 ignore else -- @preserve */\n if (set.elements.length) {\n this._imodelAccess.hiliteSet.elements.addIds(set.elements);\n this._imodelAccess.selectionSet.add(set.elements);\n }\n }\n }\n\n private removeHiliteSet(set: HiliteSet) {\n using _dispose = this.suspendIModelToolSelectionSync();\n if (is5xSelectionSet(this._imodelAccess.selectionSet)) {\n // with 5.x core we can simply remove the set as a whole\n this._imodelAccess.selectionSet.remove({\n models: set.models,\n subcategories: set.subCategories,\n elements: set.elements,\n });\n } else {\n /* v8 ignore else -- @preserve */\n if (set.models.length) {\n this._imodelAccess.hiliteSet.models.deleteIds(set.models);\n }\n /* v8 ignore else -- @preserve */\n if (set.subCategories.length) {\n this._imodelAccess.hiliteSet.subcategories.deleteIds(set.subCategories);\n }\n /* v8 ignore else -- @preserve */\n if (set.elements.length) {\n this._imodelAccess.hiliteSet.elements.deleteIds(set.elements);\n this._imodelAccess.selectionSet.remove(set.elements);\n }\n }\n }\n\n private onIModelSelectionChanged = async (event: CoreSelectionSetEventUnsafe): Promise<void> => {\n if (this._isSuspended) {\n return;\n }\n\n if (CoreSelectionSetEventType.Clear === event.type) {\n this._selectionStorage.clearSelection({ imodelKey: this._imodelAccess.key, source: this._selectionSourceName });\n return;\n }\n\n const ids = getSelectionSetChangeIds(event);\n const scopedSelection = merge(\n ids.elements\n ? from(\n computeSelection({\n queryExecutor: this._imodelAccess,\n elementIds: ids.elements,\n scope: this._activeScopeProvider(),\n componentId: this.#componentId,\n }),\n )\n : /* v8 ignore next */ EMPTY,\n ids.models\n ? from(ids.models).pipe(map((id): SelectableInstanceKey => ({ className: \"BisCore.Model\", id })))\n : /* v8 ignore next */ EMPTY,\n ids.subcategories\n ? from(ids.subcategories).pipe(map((id): SelectableInstanceKey => ({ className: \"BisCore.SubCategory\", id })))\n : /* v8 ignore next */ EMPTY,\n );\n\n const selectionStorageVersion = this._selectionStorageChangeTracker;\n const changeSelectionStorageProps = {\n imodelKey: this._imodelAccess.key,\n source: this._selectionSourceName,\n selectables: await firstValueFrom(scopedSelection.pipe(toArray())),\n };\n try {\n switch (event.type) {\n case CoreSelectionSetEventType.Add:\n return this._selectionStorage.addToSelection(changeSelectionStorageProps);\n case CoreSelectionSetEventType.Remove:\n return this._selectionStorage.removeFromSelection(changeSelectionStorageProps);\n case CoreSelectionSetEventType.Replace:\n return this._selectionStorage.replaceSelection(changeSelectionStorageProps);\n }\n } finally {\n if (this._selectionStorageChangeTracker === selectionStorageVersion) {\n // if the storage wasn't changed while we were processing the selection change, we have to re-sync the\n // hilite set (otherwise it's done by the selection storage change handler)\n this.syncHiliteSet({\n ...changeSelectionStorageProps,\n selectables: Selectables.create(changeSelectionStorageProps.selectables),\n changeType: getUnifiedSelectionChangeType(event.type),\n });\n }\n }\n };\n}\n\nfunction getSelectionSetChangeIds(\n event: Omit<CoreSelectionSetEventUnsafe, \"type\"> & {\n type: CoreSelectionSetEventType.Add | CoreSelectionSetEventType.Remove | CoreSelectionSetEventType.Replace;\n },\n): CoreSelectableIds {\n switch (event.type) {\n case CoreSelectionSetEventType.Add:\n return event.additions ?? (event.added ? { elements: event.added } : /* v8 ignore next */ {});\n case CoreSelectionSetEventType.Remove:\n return event.removals ?? (event.removed ? { elements: event.removed } : /* v8 ignore next */ {});\n case CoreSelectionSetEventType.Replace:\n return \"active\" in event.set ? event.set.active : { elements: event.set.elements };\n }\n}\n\nfunction getUnifiedSelectionChangeType(coreChangeType: CoreSelectionSetEventType): StorageSelectionChangeType {\n switch (coreChangeType) {\n case CoreSelectionSetEventType.Add:\n return \"add\";\n case CoreSelectionSetEventType.Remove:\n return \"remove\";\n case CoreSelectionSetEventType.Replace:\n return \"replace\";\n /* v8 ignore next -- @preserve */\n case CoreSelectionSetEventType.Clear:\n return \"clear\";\n }\n}\n\nfunction is5xSelectionSet(\n selectionSet: CoreIModelSelectionSet,\n): selectionSet is Omit<CoreIModelSelectionSet, \"add\" | \"remove\"> & {\n readonly active: { [P in keyof CoreSelectableIds]-?: Id64Set };\n add: (ids: Id64Arg | CoreSelectableIds) => boolean;\n remove: (ids: Id64Arg | CoreSelectableIds) => boolean;\n} {\n return \"active\" in selectionSet;\n}\n\n/* v8 ignore start */\nfunction createIModelHiliteSetProviderFromCachingProvider(\n cachingHiliteSetProvider: NonNullable<EnableUnifiedSelectionSyncWithIModelProps[\"cachingHiliteSetProvider\"]>,\n hiliteSetProvider: HiliteSetProvider,\n): IModelHiliteSetProvider {\n return {\n getHiliteSetProvider: () => hiliteSetProvider,\n getCurrentHiliteSet: (props) => cachingHiliteSetProvider.getHiliteSet(props),\n [Symbol.dispose]: () => {},\n };\n}\n/* v8 ignore stop */\n"]}
@@ -204,7 +204,9 @@ class HiliteSetProviderImpl {
204
204
  return from(executeQuery({
205
205
  queryExecutor: this._imodelAccess,
206
206
  query: { ctes, ecsql, bindings },
207
- config: { restartToken: `${this.#componentName}/${this.#componentId}/sub-categories/${Guid.createValue()}` },
207
+ config: {
208
+ restartToken: `${this.#componentName}/${this.#componentId}/sub-categories/${Guid.createValue()}`,
209
+ },
208
210
  }));
209
211
  }));
210
212
  }
@@ -216,7 +218,10 @@ class HiliteSetProviderImpl {
216
218
  elementKeys: instancesByType.element.pipe(toArray()),
217
219
  }).pipe(mergeMap(({ groupInformationElementKeys, geometricElementKeys, functionalElements, elementKeys }) => {
218
220
  const hasFunctionalElements = !!functionalElements.length;
219
- if (!groupInformationElementKeys.length && !geometricElementKeys.length && !elementKeys.length && !hasFunctionalElements) {
221
+ if (!groupInformationElementKeys.length &&
222
+ !geometricElementKeys.length &&
223
+ !elementKeys.length &&
224
+ !hasFunctionalElements) {
220
225
  return EMPTY;
221
226
  }
222
227
  const bindings = [];
@@ -262,7 +267,11 @@ class HiliteSetProviderImpl {
262
267
  `,
263
268
  ];
264
269
  const ecsql = [
265
- ...(hasFunctionalElements ? ["SELECT ECInstanceId FROM FunctionalElementChildGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)"] : []),
270
+ ...(hasFunctionalElements
271
+ ? [
272
+ "SELECT ECInstanceId FROM FunctionalElementChildGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)",
273
+ ]
274
+ : []),
266
275
  "SELECT ECInstanceId FROM GeometricElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)",
267
276
  "SELECT ECInstanceId FROM GroupGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)",
268
277
  "SELECT ECInstanceId FROM ElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)",
@@ -1 +1 @@
1
- {"version":3,"file":"HiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/HiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAChH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAehG,MAAM,yBAAyB,GAAG,EAAE,CAAC;AA0CrC;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAA6B;IACnE,OAAO,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,qBAAqB;IACjB,aAAa,CAAiD;IACtE,wCAAwC;IAChC,mBAAmB,CAAwD;IACnF,YAAY,CAAa;IACzB,cAAc,CAAS;IAEvB,YAAY,KAA6B;QACvC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,cAAc,GAAG,mBAAmB,CAAC;IAC5C,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,KAAmC;QACrD,MAAM,GAAG,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAA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AM,CAAC,CAAC,CAAC,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3B,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,KAAK,SAAS,CAAC,CAAC,YAAY,CAAC,KAI5B;IACC,KAAK,CAAC,CAAC,mBAAmB,CAAC,EAAE,GAAG,KAAK,EAAE,aAAa,EAAE,CAAC,GAAkB,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;AACpG,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\nimport { EMPTY, filter, forkJoin, from, map, merge, mergeMap, scan, shareReplay, Subject, toArray } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\nimport { formIdBindings, genericExecuteQuery, releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GuidString, Id64String } from \"@itwin/core-bentley\";\nimport type {\n EC,\n ECClassHierarchyInspector,\n ECSqlBinding,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n} from \"@itwin/presentation-shared\";\nimport type { SelectableInstanceKey, Selectables } from \"./Selectable.js\";\n\nconst HILITE_SET_EMIT_FREQUENCY = 20;\n\n/**\n * A set of model, subcategory and element ids that can be used for specifying hilite.\n *\n * **Warning:** 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 *\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/hiliteset/\n * @see `HiliteSetProvider`\n * @see `createHiliteSetProvider`\n * @public\n */\nexport interface HiliteSet {\n models: Id64String[];\n subCategories: Id64String[];\n elements: Id64String[];\n}\n\n/**\n * Props for creating a `HiliteSetProvider` instance.\n * @public\n */\nexport interface HiliteSetProviderProps {\n /** An object that provides access to iModel's metadata and allows running ECSQL queries on it. */\n imodelAccess: ECClassHierarchyInspector & ECSqlQueryExecutor;\n}\n\n/**\n * Defines return value of `createHiliteSetProvider`.\n *\n * **Warning:** 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 *\n * @see `createHiliteSetProvider`\n * @public\n */\nexport interface HiliteSetProvider {\n /** Get the current hilite set iterator for the specified imodel */\n getHiliteSet(props: { selectables: Selectables }): AsyncIterableIterator<HiliteSet>;\n}\n\n/**\n * Creates a hilite set provider that returns a `HiliteSet` for given selectables.\n * @public\n */\nexport function createHiliteSetProvider(props: HiliteSetProviderProps): HiliteSetProvider {\n return new HiliteSetProviderImpl(props);\n}\n\nclass HiliteSetProviderImpl implements HiliteSetProvider {\n private _imodelAccess: ECClassHierarchyInspector & ECSqlQueryExecutor;\n // Map between a class name and its type\n private _classRelationCache: Map<string, InstanceIdType | Promise<InstanceIdType>>;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(props: HiliteSetProviderProps) {\n this._imodelAccess = props.imodelAccess;\n this._classRelationCache = new Map();\n this.#componentId = Guid.createValue();\n this.#componentName = \"HiliteSetProvider\";\n }\n\n /**\n * Get hilite set iterator for supplied `Selectables`.\n */\n public getHiliteSet(props: { selectables: Selectables }): AsyncIterableIterator<HiliteSet> {\n const obs = this.getHiliteSetObservable(props);\n return eachValueFrom(obs);\n }\n\n /**\n * Returns a \"hot\" observable of hilite sets.\n */\n private getHiliteSetObservable({ selectables }: { selectables: Selectables }): Subject<HiliteSet> {\n const instancesByType = this.getInstancesByType(selectables);\n const observables: { [key in keyof HiliteSet]?: Observable<string> } = {\n models: this.getHilitedModels(instancesByType),\n subCategories: this.getHilitedSubCategories(instancesByType),\n elements: this.getHilitedElements(instancesByType),\n };\n\n let hiliteSet: HiliteSet = { models: [], subCategories: [], elements: [] };\n let lastEmitTime = performance.now();\n const subject = new Subject<HiliteSet>();\n const subscriptions = ([\"models\", \"subCategories\", \"elements\"] as const).map((key) =>\n observables[key]!.subscribe({\n next(val) {\n hiliteSet[key].push(val);\n if (performance.now() - lastEmitTime < HILITE_SET_EMIT_FREQUENCY) {\n return;\n }\n subject.next(hiliteSet);\n hiliteSet = { models: [], subCategories: [], elements: [] };\n lastEmitTime = performance.now();\n },\n complete() {\n observables[key] = undefined;\n if (observables.models || observables.subCategories || observables.elements) {\n return;\n }\n // Emit last batch before completing the observable.\n if (hiliteSet.elements.length || hiliteSet.models.length || hiliteSet.subCategories.length) {\n subject.next(hiliteSet);\n }\n subject.complete();\n },\n error(err) {\n subscriptions.forEach((x) => x.unsubscribe());\n subscriptions.length = 0;\n subject.error(err);\n },\n }),\n );\n\n return subject;\n }\n\n private async getType(key: SelectableInstanceKey): Promise<InstanceIdType> {\n const normalizedClassName = normalizeFullClassName(key.className);\n const cachedType = this._classRelationCache.get(normalizedClassName);\n if (cachedType) {\n return cachedType;\n }\n\n const promise = this.getTypeImpl(normalizedClassName).then((res) => {\n // Update the cache with the result of the promise.\n this._classRelationCache.set(normalizedClassName, res);\n return res;\n });\n\n // Add the promise to cache to prevent `getTypeImpl` being called multiple times.\n this._classRelationCache.set(normalizedClassName, promise);\n return promise;\n }\n\n private async getTypeImpl(fullClassName: EC.FullClassName): Promise<InstanceIdType> {\n return (\n (await this.checkType(fullClassName, \"BisCore.Subject\", \"subject\")) ??\n (await this.checkType(fullClassName, \"BisCore.Model\", \"model\")) ??\n (await this.checkType(fullClassName, \"BisCore.Category\", \"category\")) ??\n (await this.checkType(fullClassName, \"BisCore.SubCategory\", \"subCategory\")) ??\n (await this.checkType(fullClassName, \"Functional.FunctionalElement\", \"functionalElement\")) ??\n (await this.checkType(fullClassName, \"BisCore.GroupInformationElement\", \"groupInformationElement\")) ??\n (await this.checkType(fullClassName, \"BisCore.GeometricElement\", \"geometricElement\")) ??\n (await this.checkType(fullClassName, \"BisCore.Element\", \"element\")) ??\n \"unknown\"\n );\n }\n\n private async checkType(keyClassName: EC.FullClassName, checkClassName: EC.FullClassName, type: InstanceIdType) {\n try {\n const res = this._imodelAccess.classDerivesFrom(keyClassName, checkClassName);\n const isOfType = typeof res === \"boolean\" ? res : await res;\n return isOfType ? type : undefined;\n } catch (e) {\n // we may be checking against a non-existing schema (e.g. Functional), in which case we should\n // return undefined instead of throwing an error\n if (e instanceof Error && e.message.match(/Schema \"[\\w\\d_]+\" not found/)) {\n return undefined;\n }\n throw e;\n }\n }\n\n private getInstancesByType(selectables: Selectables): InstancesByType {\n const keyTypeObs = merge(\n from(selectables.custom.values()).pipe(mergeMap((selectable) => selectable.loadInstanceKeys())),\n from(selectables.instanceKeys).pipe(mergeMap(([className, idSet]) => from(idSet).pipe(map((id) => ({ className, id }))))),\n ).pipe(\n releaseMainThreadOnItemsCount(500),\n // Get types for each instance key\n mergeMap((instanceKey) => from(this.getType(instanceKey)).pipe(map((instanceIdType) => ({ instanceId: instanceKey.id, instanceIdType })))),\n // Cache the results\n shareReplay(),\n );\n\n return Object.fromEntries(\n INSTANCE_TYPES.map((type) => [\n type,\n keyTypeObs.pipe(\n filter(({ instanceIdType }) => instanceIdType === type),\n map(({ instanceId }) => instanceId),\n unique(),\n ),\n ]),\n ) as InstancesByType;\n }\n\n private getHilitedModels(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n modelKeys: instancesByType.model.pipe(toArray()),\n subjectKeys: instancesByType.subject.pipe(toArray()),\n }).pipe(\n mergeMap(({ modelKeys, subjectKeys }) => {\n if (!modelKeys.length && !subjectKeys.length) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n `\n ChildSubjects(ECInstanceId, JsonProperties) AS (\n SELECT ECInstanceId, JsonProperties\n FROM BisCore.Subject\n WHERE ${formIdBindings(\"ECInstanceId\", subjectKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.JsonProperties\n FROM ChildSubjects s\n JOIN BisCore.Subject r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n Models(ECInstanceId) AS (\n SELECT s.ECInstanceId AS ECInstanceId\n FROM BisCore.Model s\n WHERE ${formIdBindings(\"ECInstanceId\", modelKeys, bindings)}\n )\n `,\n ];\n const ecsql = [\n `\n SELECT r.ECInstanceId AS ECInstanceId\n FROM ChildSubjects s\n JOIN BisCore.PhysicalPartition r ON r.Parent.Id = s.ECInstanceId OR json_extract(s.JsonProperties,'$.Subject.Model.TargetPartition') = printf('0x%x', r.ECInstanceId)\n `,\n `\n SELECT ECInstanceId FROM Models\n `,\n ].join(\" UNION \");\n return from(\n executeQuery({\n queryExecutor: this._imodelAccess,\n query: { ctes, ecsql, bindings },\n config: { restartToken: `${this.#componentName}/${this.#componentId}/models/${Guid.createValue()}` },\n }),\n );\n }),\n );\n }\n\n private getHilitedSubCategories(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n subCategoryKeys: instancesByType.subCategory.pipe(toArray()),\n categoryKeys: instancesByType.category.pipe(toArray()),\n }).pipe(\n mergeMap(({ subCategoryKeys, categoryKeys }) => {\n if (!subCategoryKeys.length && !categoryKeys.length) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n `\n CategorySubCategories(ECInstanceId) AS (\n SELECT r.ECInstanceId AS ECInstanceId\n FROM BisCore.Category s\n JOIN BisCore.SubCategory r ON r.Parent.Id = s.ECInstanceId\n WHERE ${formIdBindings(\"s.ECInstanceId\", categoryKeys, bindings)}\n )\n `,\n `\n SubCategories(ECInstanceId) AS (\n SELECT s.ECInstanceId AS ECInstanceId\n FROM BisCore.SubCategory s\n WHERE ${formIdBindings(\"s.ECInstanceId\", subCategoryKeys, bindings)}\n )\n `,\n ];\n const ecsql = [`SELECT ECInstanceId FROM CategorySubCategories`, `SELECT ECInstanceId FROM SubCategories`].join(\" UNION \");\n return from(\n executeQuery({\n queryExecutor: this._imodelAccess,\n query: { ctes, ecsql, bindings },\n config: { restartToken: `${this.#componentName}/${this.#componentId}/sub-categories/${Guid.createValue()}` },\n }),\n );\n }),\n );\n }\n\n private getHilitedElements(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n groupInformationElementKeys: instancesByType.groupInformationElement.pipe(toArray()),\n geometricElementKeys: instancesByType.geometricElement.pipe(toArray()),\n functionalElements: instancesByType.functionalElement.pipe(toArray()),\n elementKeys: instancesByType.element.pipe(toArray()),\n }).pipe(\n mergeMap(({ groupInformationElementKeys, geometricElementKeys, functionalElements, elementKeys }) => {\n const hasFunctionalElements = !!functionalElements.length;\n if (!groupInformationElementKeys.length && !geometricElementKeys.length && !elementKeys.length && !hasFunctionalElements) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n ...(hasFunctionalElements ? this.getHilitedFunctionalElementsQueryCTEs(functionalElements, bindings) : []),\n `\n GroupMembers(ECInstanceId, ECClassId) AS (\n SELECT TargetECInstanceId, TargetECClassId\n FROM BisCore.ElementGroupsMembers\n WHERE ${formIdBindings(\"SourceECInstanceId\", groupInformationElementKeys, bindings)}\n )\n `,\n `\n GroupGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM GroupMembers\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM GroupGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n ElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", elementKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM ElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n GeometricElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM BisCore.GeometricElement\n WHERE ${formIdBindings(\"ECInstanceId\", geometricElementKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM GeometricElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n ];\n const ecsql = [\n ...(hasFunctionalElements ? [\"SELECT ECInstanceId FROM FunctionalElementChildGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\"] : []),\n \"SELECT ECInstanceId FROM GeometricElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n \"SELECT ECInstanceId FROM GroupGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n \"SELECT ECInstanceId FROM ElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n ].join(\" UNION \");\n return from(\n executeQuery({\n queryExecutor: this._imodelAccess,\n query: { ctes, ecsql, bindings },\n config: { restartToken: `${this.#componentName}/${this.#componentId}/elements/${Guid.createValue()}` },\n }),\n );\n }),\n );\n }\n\n private getHilitedFunctionalElementsQueryCTEs(functionalElements: string[], bindings: ECSqlBinding[]): string[] {\n return [\n `\n ChildFunctionalElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM Functional.FunctionalElement\n WHERE ${formIdBindings(\"ECInstanceId\", functionalElements, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.FunctionalElement r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n PhysicalElements(ECInstanceId, ECClassId) AS (\n SELECT r.SourceECInstanceId, r.SourceECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.PhysicalElementFulfillsFunction r ON r.TargetECInstanceId = s.ECInstanceId\n )\n `,\n `\n DrawingGraphicElements(ECInstanceId, ECClassId) AS (\n SELECT r.SourceECInstanceId, r.SourceECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.DrawingGraphicRepresentsFunctionalElement r ON r.TargetECInstanceId = s.ECInstanceId\n )\n `,\n `\n PhysicalElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM PhysicalElements\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM PhysicalElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n DrawingGraphicElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM DrawingGraphicElements\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM DrawingGraphicElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n FunctionalElementChildGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM PhysicalElementGeometricElements\n UNION\n SELECT ECInstanceId, ECClassId FROM DrawingGraphicElementGeometricElements\n )\n `,\n ];\n }\n}\n\nconst INSTANCE_TYPES = [\n \"subject\",\n \"model\",\n \"category\",\n \"subCategory\",\n \"functionalElement\",\n \"groupInformationElement\",\n \"geometricElement\",\n \"element\",\n \"unknown\",\n] as const;\n\ntype InstanceIdType = (typeof INSTANCE_TYPES)[number];\n\ntype InstancesByType = {\n [idType in InstanceIdType]: Observable<string>;\n};\n\nfunction unique<T>() {\n return function (obs: Observable<T>): Observable<T> {\n return obs.pipe(\n scan(\n (acc, val) => {\n if (acc.set.has(val)) {\n delete acc.val;\n return acc;\n }\n\n acc.set.add(val);\n acc.val = val;\n return acc;\n },\n { set: new Set<T>() } as { set: Set<T>; val?: T },\n ),\n map(({ val }) => val),\n filter((x): x is T => !!x),\n );\n };\n}\n\nasync function* executeQuery(props: {\n queryExecutor: ECSqlQueryExecutor;\n query: ECSqlQueryDef;\n config?: ECSqlQueryReaderOptions;\n}): AsyncIterableIterator<string> {\n yield* genericExecuteQuery({ ...props, parseQueryRow: (row: ECSqlQueryRow) => row.ECInstanceId });\n}\n"]}
1
+ {"version":3,"file":"HiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/HiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,Q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C,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;AACpG,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\nimport { EMPTY, filter, forkJoin, from, map, merge, mergeMap, scan, shareReplay, Subject, toArray } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\nimport { formIdBindings, genericExecuteQuery, releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\nimport type { Observable } from \"rxjs\";\nimport type { GuidString, Id64String } from \"@itwin/core-bentley\";\nimport type {\n EC,\n ECClassHierarchyInspector,\n ECSqlBinding,\n ECSqlQueryDef,\n ECSqlQueryExecutor,\n ECSqlQueryReaderOptions,\n ECSqlQueryRow,\n} from \"@itwin/presentation-shared\";\nimport type { SelectableInstanceKey, Selectables } from \"./Selectable.js\";\n\nconst HILITE_SET_EMIT_FREQUENCY = 20;\n\n/**\n * A set of model, subcategory and element ids that can be used for specifying hilite.\n *\n * **Warning:** 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 *\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/hiliteset/\n * @see `HiliteSetProvider`\n * @see `createHiliteSetProvider`\n * @public\n */\nexport interface HiliteSet {\n models: Id64String[];\n subCategories: Id64String[];\n elements: Id64String[];\n}\n\n/**\n * Props for creating a `HiliteSetProvider` instance.\n * @public\n */\nexport interface HiliteSetProviderProps {\n /** An object that provides access to iModel's metadata and allows running ECSQL queries on it. */\n imodelAccess: ECClassHierarchyInspector & ECSqlQueryExecutor;\n}\n\n/**\n * Defines return value of `createHiliteSetProvider`.\n *\n * **Warning:** 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 *\n * @see `createHiliteSetProvider`\n * @public\n */\nexport interface HiliteSetProvider {\n /** Get the current hilite set iterator for the specified imodel */\n getHiliteSet(props: { selectables: Selectables }): AsyncIterableIterator<HiliteSet>;\n}\n\n/**\n * Creates a hilite set provider that returns a `HiliteSet` for given selectables.\n * @public\n */\nexport function createHiliteSetProvider(props: HiliteSetProviderProps): HiliteSetProvider {\n return new HiliteSetProviderImpl(props);\n}\n\nclass HiliteSetProviderImpl implements HiliteSetProvider {\n private _imodelAccess: ECClassHierarchyInspector & ECSqlQueryExecutor;\n // Map between a class name and its type\n private _classRelationCache: Map<string, InstanceIdType | Promise<InstanceIdType>>;\n #componentId: GuidString;\n #componentName: string;\n\n constructor(props: HiliteSetProviderProps) {\n this._imodelAccess = props.imodelAccess;\n this._classRelationCache = new Map();\n this.#componentId = Guid.createValue();\n this.#componentName = \"HiliteSetProvider\";\n }\n\n /**\n * Get hilite set iterator for supplied `Selectables`.\n */\n public getHiliteSet(props: { selectables: Selectables }): AsyncIterableIterator<HiliteSet> {\n const obs = this.getHiliteSetObservable(props);\n return eachValueFrom(obs);\n }\n\n /**\n * Returns a \"hot\" observable of hilite sets.\n */\n private getHiliteSetObservable({ selectables }: { selectables: Selectables }): Subject<HiliteSet> {\n const instancesByType = this.getInstancesByType(selectables);\n const observables: { [key in keyof HiliteSet]?: Observable<string> } = {\n models: this.getHilitedModels(instancesByType),\n subCategories: this.getHilitedSubCategories(instancesByType),\n elements: this.getHilitedElements(instancesByType),\n };\n\n let hiliteSet: HiliteSet = { models: [], subCategories: [], elements: [] };\n let lastEmitTime = performance.now();\n const subject = new Subject<HiliteSet>();\n const subscriptions = ([\"models\", \"subCategories\", \"elements\"] as const).map((key) =>\n observables[key]!.subscribe({\n next(val) {\n hiliteSet[key].push(val);\n if (performance.now() - lastEmitTime < HILITE_SET_EMIT_FREQUENCY) {\n return;\n }\n subject.next(hiliteSet);\n hiliteSet = { models: [], subCategories: [], elements: [] };\n lastEmitTime = performance.now();\n },\n complete() {\n observables[key] = undefined;\n if (observables.models || observables.subCategories || observables.elements) {\n return;\n }\n // Emit last batch before completing the observable.\n if (hiliteSet.elements.length || hiliteSet.models.length || hiliteSet.subCategories.length) {\n subject.next(hiliteSet);\n }\n subject.complete();\n },\n error(err) {\n subscriptions.forEach((x) => x.unsubscribe());\n subscriptions.length = 0;\n subject.error(err);\n },\n }),\n );\n\n return subject;\n }\n\n private async getType(key: SelectableInstanceKey): Promise<InstanceIdType> {\n const normalizedClassName = normalizeFullClassName(key.className);\n const cachedType = this._classRelationCache.get(normalizedClassName);\n if (cachedType) {\n return cachedType;\n }\n\n const promise = this.getTypeImpl(normalizedClassName).then((res) => {\n // Update the cache with the result of the promise.\n this._classRelationCache.set(normalizedClassName, res);\n return res;\n });\n\n // Add the promise to cache to prevent `getTypeImpl` being called multiple times.\n this._classRelationCache.set(normalizedClassName, promise);\n return promise;\n }\n\n private async getTypeImpl(fullClassName: EC.FullClassName): Promise<InstanceIdType> {\n return (\n (await this.checkType(fullClassName, \"BisCore.Subject\", \"subject\")) ??\n (await this.checkType(fullClassName, \"BisCore.Model\", \"model\")) ??\n (await this.checkType(fullClassName, \"BisCore.Category\", \"category\")) ??\n (await this.checkType(fullClassName, \"BisCore.SubCategory\", \"subCategory\")) ??\n (await this.checkType(fullClassName, \"Functional.FunctionalElement\", \"functionalElement\")) ??\n (await this.checkType(fullClassName, \"BisCore.GroupInformationElement\", \"groupInformationElement\")) ??\n (await this.checkType(fullClassName, \"BisCore.GeometricElement\", \"geometricElement\")) ??\n (await this.checkType(fullClassName, \"BisCore.Element\", \"element\")) ??\n \"unknown\"\n );\n }\n\n private async checkType(keyClassName: EC.FullClassName, checkClassName: EC.FullClassName, type: InstanceIdType) {\n try {\n const res = this._imodelAccess.classDerivesFrom(keyClassName, checkClassName);\n const isOfType = typeof res === \"boolean\" ? res : await res;\n return isOfType ? type : undefined;\n } catch (e) {\n // we may be checking against a non-existing schema (e.g. Functional), in which case we should\n // return undefined instead of throwing an error\n if (e instanceof Error && e.message.match(/Schema \"[\\w\\d_]+\" not found/)) {\n return undefined;\n }\n throw e;\n }\n }\n\n private getInstancesByType(selectables: Selectables): InstancesByType {\n const keyTypeObs = merge(\n from(selectables.custom.values()).pipe(mergeMap((selectable) => selectable.loadInstanceKeys())),\n from(selectables.instanceKeys).pipe(\n mergeMap(([className, idSet]) => from(idSet).pipe(map((id) => ({ className, id })))),\n ),\n ).pipe(\n releaseMainThreadOnItemsCount(500),\n // Get types for each instance key\n mergeMap((instanceKey) =>\n from(this.getType(instanceKey)).pipe(map((instanceIdType) => ({ instanceId: instanceKey.id, instanceIdType }))),\n ),\n // Cache the results\n shareReplay(),\n );\n\n return Object.fromEntries(\n INSTANCE_TYPES.map((type) => [\n type,\n keyTypeObs.pipe(\n filter(({ instanceIdType }) => instanceIdType === type),\n map(({ instanceId }) => instanceId),\n unique(),\n ),\n ]),\n ) as InstancesByType;\n }\n\n private getHilitedModels(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n modelKeys: instancesByType.model.pipe(toArray()),\n subjectKeys: instancesByType.subject.pipe(toArray()),\n }).pipe(\n mergeMap(({ modelKeys, subjectKeys }) => {\n if (!modelKeys.length && !subjectKeys.length) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n `\n ChildSubjects(ECInstanceId, JsonProperties) AS (\n SELECT ECInstanceId, JsonProperties\n FROM BisCore.Subject\n WHERE ${formIdBindings(\"ECInstanceId\", subjectKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.JsonProperties\n FROM ChildSubjects s\n JOIN BisCore.Subject r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n Models(ECInstanceId) AS (\n SELECT s.ECInstanceId AS ECInstanceId\n FROM BisCore.Model s\n WHERE ${formIdBindings(\"ECInstanceId\", modelKeys, bindings)}\n )\n `,\n ];\n const ecsql = [\n `\n SELECT r.ECInstanceId AS ECInstanceId\n FROM ChildSubjects s\n JOIN BisCore.PhysicalPartition r ON r.Parent.Id = s.ECInstanceId OR json_extract(s.JsonProperties,'$.Subject.Model.TargetPartition') = printf('0x%x', r.ECInstanceId)\n `,\n `\n SELECT ECInstanceId FROM Models\n `,\n ].join(\" UNION \");\n return from(\n executeQuery({\n queryExecutor: this._imodelAccess,\n query: { ctes, ecsql, bindings },\n config: { restartToken: `${this.#componentName}/${this.#componentId}/models/${Guid.createValue()}` },\n }),\n );\n }),\n );\n }\n\n private getHilitedSubCategories(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n subCategoryKeys: instancesByType.subCategory.pipe(toArray()),\n categoryKeys: instancesByType.category.pipe(toArray()),\n }).pipe(\n mergeMap(({ subCategoryKeys, categoryKeys }) => {\n if (!subCategoryKeys.length && !categoryKeys.length) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n `\n CategorySubCategories(ECInstanceId) AS (\n SELECT r.ECInstanceId AS ECInstanceId\n FROM BisCore.Category s\n JOIN BisCore.SubCategory r ON r.Parent.Id = s.ECInstanceId\n WHERE ${formIdBindings(\"s.ECInstanceId\", categoryKeys, bindings)}\n )\n `,\n `\n SubCategories(ECInstanceId) AS (\n SELECT s.ECInstanceId AS ECInstanceId\n FROM BisCore.SubCategory s\n WHERE ${formIdBindings(\"s.ECInstanceId\", subCategoryKeys, bindings)}\n )\n `,\n ];\n const ecsql = [`SELECT ECInstanceId FROM CategorySubCategories`, `SELECT ECInstanceId FROM SubCategories`].join(\n \" UNION \",\n );\n return from(\n executeQuery({\n queryExecutor: this._imodelAccess,\n query: { ctes, ecsql, bindings },\n config: {\n restartToken: `${this.#componentName}/${this.#componentId}/sub-categories/${Guid.createValue()}`,\n },\n }),\n );\n }),\n );\n }\n\n private getHilitedElements(instancesByType: InstancesByType): Observable<string> {\n return forkJoin({\n groupInformationElementKeys: instancesByType.groupInformationElement.pipe(toArray()),\n geometricElementKeys: instancesByType.geometricElement.pipe(toArray()),\n functionalElements: instancesByType.functionalElement.pipe(toArray()),\n elementKeys: instancesByType.element.pipe(toArray()),\n }).pipe(\n mergeMap(({ groupInformationElementKeys, geometricElementKeys, functionalElements, elementKeys }) => {\n const hasFunctionalElements = !!functionalElements.length;\n if (\n !groupInformationElementKeys.length &&\n !geometricElementKeys.length &&\n !elementKeys.length &&\n !hasFunctionalElements\n ) {\n return EMPTY;\n }\n\n const bindings: ECSqlBinding[] = [];\n const ctes = [\n ...(hasFunctionalElements ? this.getHilitedFunctionalElementsQueryCTEs(functionalElements, bindings) : []),\n `\n GroupMembers(ECInstanceId, ECClassId) AS (\n SELECT TargetECInstanceId, TargetECClassId\n FROM BisCore.ElementGroupsMembers\n WHERE ${formIdBindings(\"SourceECInstanceId\", groupInformationElementKeys, bindings)}\n )\n `,\n `\n GroupGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM GroupMembers\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM GroupGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n ElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM BisCore.Element\n WHERE ${formIdBindings(\"ECInstanceId\", elementKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM ElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n GeometricElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM BisCore.GeometricElement\n WHERE ${formIdBindings(\"ECInstanceId\", geometricElementKeys, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM GeometricElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n ];\n const ecsql = [\n ...(hasFunctionalElements\n ? [\n \"SELECT ECInstanceId FROM FunctionalElementChildGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n ]\n : []),\n \"SELECT ECInstanceId FROM GeometricElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n \"SELECT ECInstanceId FROM GroupGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n \"SELECT ECInstanceId FROM ElementGeometricElements WHERE ECClassId IS (BisCore.GeometricElement)\",\n ].join(\" UNION \");\n return from(\n executeQuery({\n queryExecutor: this._imodelAccess,\n query: { ctes, ecsql, bindings },\n config: { restartToken: `${this.#componentName}/${this.#componentId}/elements/${Guid.createValue()}` },\n }),\n );\n }),\n );\n }\n\n private getHilitedFunctionalElementsQueryCTEs(functionalElements: string[], bindings: ECSqlBinding[]): string[] {\n return [\n `\n ChildFunctionalElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId\n FROM Functional.FunctionalElement\n WHERE ${formIdBindings(\"ECInstanceId\", functionalElements, bindings)}\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.FunctionalElement r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n PhysicalElements(ECInstanceId, ECClassId) AS (\n SELECT r.SourceECInstanceId, r.SourceECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.PhysicalElementFulfillsFunction r ON r.TargetECInstanceId = s.ECInstanceId\n )\n `,\n `\n DrawingGraphicElements(ECInstanceId, ECClassId) AS (\n SELECT r.SourceECInstanceId, r.SourceECClassId\n FROM ChildFunctionalElements s\n JOIN Functional.DrawingGraphicRepresentsFunctionalElement r ON r.TargetECInstanceId = s.ECInstanceId\n )\n `,\n `\n PhysicalElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM PhysicalElements\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM PhysicalElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n DrawingGraphicElementGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM DrawingGraphicElements\n UNION ALL\n SELECT r.ECInstanceId, r.ECClassId\n FROM DrawingGraphicElementGeometricElements s\n JOIN BisCore.Element r ON r.Parent.Id = s.ECInstanceId\n )\n `,\n `\n FunctionalElementChildGeometricElements(ECInstanceId, ECClassId) AS (\n SELECT ECInstanceId, ECClassId FROM PhysicalElementGeometricElements\n UNION\n SELECT ECInstanceId, ECClassId FROM DrawingGraphicElementGeometricElements\n )\n `,\n ];\n }\n}\n\nconst INSTANCE_TYPES = [\n \"subject\",\n \"model\",\n \"category\",\n \"subCategory\",\n \"functionalElement\",\n \"groupInformationElement\",\n \"geometricElement\",\n \"element\",\n \"unknown\",\n] as const;\n\ntype InstanceIdType = (typeof INSTANCE_TYPES)[number];\n\ntype InstancesByType = {\n [idType in InstanceIdType]: Observable<string>;\n};\n\nfunction unique<T>() {\n return function (obs: Observable<T>): Observable<T> {\n return obs.pipe(\n scan(\n (acc, val) => {\n if (acc.set.has(val)) {\n delete acc.val;\n return acc;\n }\n\n acc.set.add(val);\n acc.val = val;\n return acc;\n },\n { set: new Set<T>() } as { set: Set<T>; val?: T },\n ),\n map(({ val }) => val),\n filter((x): x is T => !!x),\n );\n };\n}\n\nasync function* executeQuery(props: {\n queryExecutor: ECSqlQueryExecutor;\n query: ECSqlQueryDef;\n config?: ECSqlQueryReaderOptions;\n}): AsyncIterableIterator<string> {\n yield* genericExecuteQuery({ ...props, parseQueryRow: (row: ECSqlQueryRow) => row.ECInstanceId });\n}\n"]}
@@ -34,7 +34,8 @@ class IModelHiliteSetProviderImpl {
34
34
  this._hiliteSetProviders.delete(args.imodelKey);
35
35
  }
36
36
  });
37
- this._createHiliteSetProvider = props.createHiliteSetProvider ?? /* c8 ignore next */ createHiliteSetProvider;
37
+ /* v8 ignore next -- @preserve */
38
+ this._createHiliteSetProvider = props.createHiliteSetProvider ?? createHiliteSetProvider;
38
39
  }
39
40
  getHiliteSetProvider({ imodelKey }) {
40
41
  let provider = this._hiliteSetProviders.get(imodelKey);