@itwin/presentation-frontend 5.0.0-dev.3 → 5.0.0-dev.32

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 (50) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  3. package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
  4. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  5. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  6. package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
  7. package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
  8. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  9. package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
  10. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  11. package/lib/cjs/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
  12. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +7 -7
  13. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  14. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  15. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  16. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  17. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  18. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  19. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  20. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +14 -1
  21. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
  22. package/lib/cjs/presentation-frontend/selection/SelectionManager.js +73 -47
  23. package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
  24. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  25. package/lib/cjs/presentation-frontend.js.map +1 -1
  26. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  27. package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
  28. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  29. package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  30. package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
  31. package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
  32. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  33. package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
  34. package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  35. package/lib/esm/presentation-frontend/StreamedResponseGenerator.js.map +1 -1
  36. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +7 -7
  37. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  38. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  39. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  40. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  41. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  42. package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  43. package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  44. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +14 -1
  45. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
  46. package/lib/esm/presentation-frontend/selection/SelectionManager.js +73 -47
  47. package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
  48. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  49. package/lib/esm/presentation-frontend.js.map +1 -1
  50. package/package.json +18 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CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B,EAAE,CAAC;gBAC5E,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO;YACL,YAAY;YACZ,IAAI;SACL,CAAC;IACJ,CAAC;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,MAAM,aAAa,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC;AAElF,MAAM,mBAAmB,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { from, Observable, shareReplay } from \"rxjs\";\r\nimport { eachValueFrom } from \"rxjs-for-await\";\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { ContentFlags, DEFAULT_KEYS_BATCH_SIZE, DefaultContentDisplayTypes, DescriptorOverrides, Item, Key, KeySet, Ruleset } from \"@itwin/presentation-common\";\r\nimport { Presentation } from \"../Presentation\";\r\nimport hiliteRuleset from \"./HiliteRules.json\";\r\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"@itwin/unified-selection\";\r\n\r\nconst HILITE_RULESET = hiliteRuleset as Ruleset;\r\n\r\n/**\r\n * A set of model, subcategory and element ids that can be used for specifying\r\n * viewport hilite.\r\n *\r\n * @public\r\n */\r\nexport interface HiliteSet {\r\n models?: Id64String[];\r\n subCategories?: Id64String[];\r\n elements?: Id64String[];\r\n}\r\n\r\n/**\r\n * Properties for creating a `HiliteSetProvider` instance.\r\n * @public\r\n */\r\nexport interface HiliteSetProviderProps {\r\n imodel: IModelConnection;\r\n}\r\n\r\n/**\r\n * Presentation-based provider which uses presentation ruleset to determine\r\n * what `HiliteSet` should be hilited in the graphics viewport based on the\r\n * supplied `KeySet`.\r\n *\r\n * @public\r\n */\r\nexport class HiliteSetProvider {\r\n private _imodel: IModelConnection;\r\n private _cache: undefined | { keysGuid: string; observable: Observable<HiliteSet> };\r\n\r\n private constructor(props: HiliteSetProviderProps) {\r\n this._imodel = props.imodel;\r\n }\r\n\r\n /**\r\n * Create a hilite set provider for the specified iModel.\r\n */\r\n public static create(props: HiliteSetProviderProps) {\r\n return new HiliteSetProvider(props);\r\n }\r\n\r\n /**\r\n * Get hilite set for instances and/or nodes whose keys are specified in the\r\n * given KeySet.\r\n *\r\n * Note: The provider caches result of the last request, so subsequent requests\r\n * for the same input doesn't cost.\r\n */\r\n public async getHiliteSet(selection: Readonly<KeySet>): Promise<HiliteSet> {\r\n const modelIds = new Array<Id64String>();\r\n const subCategoryIds = new Array<Id64String>();\r\n const elementIds = new Array<Id64String>();\r\n\r\n const iterator = this.getHiliteSetIterator(selection);\r\n for await (const set of iterator) {\r\n modelIds.push(...(set.models ?? []));\r\n subCategoryIds.push(...(set.subCategories ?? []));\r\n elementIds.push(...(set.elements ?? []));\r\n }\r\n\r\n return {\r\n models: modelIds.length ? modelIds : undefined,\r\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\r\n elements: elementIds.length ? elementIds : undefined,\r\n };\r\n }\r\n\r\n /**\r\n * Get hilite set iterator for provided keys. It loads content in batches and\r\n * yields hilite set created from each batch after it is loaded.\r\n */\r\n public getHiliteSetIterator(selection: Readonly<KeySet>) {\r\n if (!this._cache || this._cache.keysGuid !== selection.guid) {\r\n this._cache = {\r\n keysGuid: selection.guid,\r\n observable: from(this.createHiliteSetIterator(selection)).pipe(shareReplay({ refCount: true })),\r\n };\r\n }\r\n\r\n return eachValueFrom(this._cache.observable);\r\n }\r\n\r\n private async *createHiliteSetIterator(selection: Readonly<KeySet>) {\r\n const { keys, transientIds } = this.handleTransientKeys(selection);\r\n const { options, keyBatches } = this.getContentOptions(keys);\r\n\r\n if (transientIds.length !== 0) {\r\n yield { elements: transientIds };\r\n }\r\n\r\n for (const batch of keyBatches) {\r\n let loadedItems = 0;\r\n while (true) {\r\n const content = await Presentation.presentation.getContentIterator({\r\n ...options,\r\n paging: { start: loadedItems, size: CONTENT_SET_PAGE_SIZE },\r\n keys: batch,\r\n });\r\n if (!content) {\r\n break;\r\n }\r\n\r\n const items = new Array<Item>();\r\n for await (const item of content.items) {\r\n items.push(item);\r\n }\r\n const result = this.createHiliteSet(items);\r\n yield result;\r\n\r\n loadedItems += items.length;\r\n if (loadedItems >= content.total) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n private createHiliteSet(records: Item[]): HiliteSet {\r\n const modelIds = new Array<Id64String>();\r\n const subCategoryIds = new Array<Id64String>();\r\n const elementIds = new Array<Id64String>();\r\n records.forEach((rec) => {\r\n const ids = isModelRecord(rec) ? modelIds : isSubCategoryRecord(rec) ? subCategoryIds : elementIds;\r\n rec.primaryKeys.forEach((pk) => ids.push(pk.id));\r\n });\r\n return {\r\n models: modelIds.length ? modelIds : undefined,\r\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\r\n elements: elementIds.length ? elementIds : undefined,\r\n };\r\n }\r\n\r\n private getContentOptions(keys: KeySet) {\r\n const descriptor: DescriptorOverrides = {\r\n displayType: DefaultContentDisplayTypes.Viewport,\r\n contentFlags: ContentFlags.KeysOnly,\r\n };\r\n const options = {\r\n imodel: this._imodel,\r\n rulesetOrId: HILITE_RULESET,\r\n descriptor,\r\n };\r\n const keyBatches = new Array<KeySet>();\r\n keys.forEachBatch(DEFAULT_KEYS_BATCH_SIZE, (batch: KeySet) => {\r\n keyBatches.push(batch);\r\n });\r\n return {\r\n options,\r\n keyBatches,\r\n };\r\n }\r\n\r\n private handleTransientKeys(selection: Readonly<KeySet>) {\r\n // need to create a new set without transients\r\n const transientIds = new Array<Id64String>();\r\n const keys = new KeySet();\r\n keys.add(selection, (key: Key) => {\r\n if (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) {\r\n transientIds.push(key.id);\r\n return false;\r\n }\r\n return true;\r\n });\r\n return {\r\n transientIds,\r\n keys,\r\n };\r\n }\r\n}\r\n\r\nconst CONTENT_SET_PAGE_SIZE = 1000;\r\n\r\nconst isModelRecord = (rec: Item) => rec.extendedData && rec.extendedData.isModel;\r\n\r\nconst isSubCategoryRecord = (rec: Item) => rec.extendedData && rec.extendedData.isSubCategory;\r\n"]}
1
+ {"version":3,"file":"HiliteSetProvider.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/HiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,0BAA0B,EAA6B,GAAG,EAAE,MAAM,EAAW,MAAM,4BAA4B,CAAC;AAChK,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,MAAM,cAAc,GAAG,aAAwB,CAAC;AAsBhD;;;;;;GAMG;AACH,MAAM,OAAO,iBAAiB;IAI5B,YAAoB,KAA6B;QAC/C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,MAAM,CAAC,KAA6B;QAChD,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC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AAC;QACvC,IAAI,CAAC,YAAY,CAAC,uBAAuB,EAAE,CAAC,KAAa,EAAE,EAAE;YAC3D,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,OAAO;YACL,OAAO;YACP,UAAU;SACX,CAAC;IACJ,CAAC;IAEO,mBAAmB,CAAC,SAA2B;QACrD,8CAA8C;QAC9C,MAAM,YAAY,GAAG,IAAI,KAAK,EAAc,CAAC;QAC7C,MAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAQ,EAAE,EAAE;YAC/B,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B,EAAE,CAAC;gBAC5E,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO;YACL,YAAY;YACZ,IAAI;SACL,CAAC;IACJ,CAAC;CACF;AAED,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC,MAAM,aAAa,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC;AAElF,MAAM,mBAAmB,GAAG,CAAC,GAAS,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { from, Observable, shareReplay } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { ContentFlags, DEFAULT_KEYS_BATCH_SIZE, DefaultContentDisplayTypes, DescriptorOverrides, Item, Key, KeySet, Ruleset } from \"@itwin/presentation-common\";\nimport { Presentation } from \"../Presentation\";\nimport hiliteRuleset from \"./HiliteRules.json\";\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"@itwin/unified-selection\";\n\nconst HILITE_RULESET = hiliteRuleset as Ruleset;\n\n/**\n * A set of model, subcategory and element ids that can be used for specifying\n * viewport hilite.\n *\n * @public\n */\nexport interface HiliteSet {\n models?: Id64String[];\n subCategories?: Id64String[];\n elements?: Id64String[];\n}\n\n/**\n * Properties for creating a `HiliteSetProvider` instance.\n * @public\n */\nexport interface HiliteSetProviderProps {\n imodel: IModelConnection;\n}\n\n/**\n * Presentation-based provider which uses presentation ruleset to determine\n * what `HiliteSet` should be hilited in the graphics viewport based on the\n * supplied `KeySet`.\n *\n * @public\n */\nexport class HiliteSetProvider {\n private _imodel: IModelConnection;\n private _cache: undefined | { keysGuid: string; observable: Observable<HiliteSet> };\n\n private constructor(props: HiliteSetProviderProps) {\n this._imodel = props.imodel;\n }\n\n /**\n * Create a hilite set provider for the specified iModel.\n */\n public static create(props: HiliteSetProviderProps) {\n return new HiliteSetProvider(props);\n }\n\n /**\n * Get hilite set for instances and/or nodes whose keys are specified in the\n * given KeySet.\n *\n * Note: The provider caches result of the last request, so subsequent requests\n * for the same input doesn't cost.\n */\n public async getHiliteSet(selection: Readonly<KeySet>): Promise<HiliteSet> {\n const modelIds = new Array<Id64String>();\n const subCategoryIds = new Array<Id64String>();\n const elementIds = new Array<Id64String>();\n\n const iterator = this.getHiliteSetIterator(selection);\n for await (const set of iterator) {\n modelIds.push(...(set.models ?? []));\n subCategoryIds.push(...(set.subCategories ?? []));\n elementIds.push(...(set.elements ?? []));\n }\n\n return {\n models: modelIds.length ? modelIds : undefined,\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\n elements: elementIds.length ? elementIds : undefined,\n };\n }\n\n /**\n * Get hilite set iterator for provided keys. It loads content in batches and\n * yields hilite set created from each batch after it is loaded.\n */\n public getHiliteSetIterator(selection: Readonly<KeySet>) {\n if (!this._cache || this._cache.keysGuid !== selection.guid) {\n this._cache = {\n keysGuid: selection.guid,\n observable: from(this.createHiliteSetIterator(selection)).pipe(shareReplay({ refCount: true })),\n };\n }\n\n return eachValueFrom(this._cache.observable);\n }\n\n private async *createHiliteSetIterator(selection: Readonly<KeySet>) {\n const { keys, transientIds } = this.handleTransientKeys(selection);\n const { options, keyBatches } = this.getContentOptions(keys);\n\n if (transientIds.length !== 0) {\n yield { elements: transientIds };\n }\n\n for (const batch of keyBatches) {\n let loadedItems = 0;\n while (true) {\n const content = await Presentation.presentation.getContentIterator({\n ...options,\n paging: { start: loadedItems, size: CONTENT_SET_PAGE_SIZE },\n keys: batch,\n });\n if (!content) {\n break;\n }\n\n const items = new Array<Item>();\n for await (const item of content.items) {\n items.push(item);\n }\n const result = this.createHiliteSet(items);\n yield result;\n\n loadedItems += items.length;\n if (loadedItems >= content.total) {\n break;\n }\n }\n }\n }\n\n private createHiliteSet(records: Item[]): HiliteSet {\n const modelIds = new Array<Id64String>();\n const subCategoryIds = new Array<Id64String>();\n const elementIds = new Array<Id64String>();\n records.forEach((rec) => {\n const ids = isModelRecord(rec) ? modelIds : isSubCategoryRecord(rec) ? subCategoryIds : elementIds;\n rec.primaryKeys.forEach((pk) => ids.push(pk.id));\n });\n return {\n models: modelIds.length ? modelIds : undefined,\n subCategories: subCategoryIds.length ? subCategoryIds : undefined,\n elements: elementIds.length ? elementIds : undefined,\n };\n }\n\n private getContentOptions(keys: KeySet) {\n const descriptor: DescriptorOverrides = {\n displayType: DefaultContentDisplayTypes.Viewport,\n contentFlags: ContentFlags.KeysOnly,\n };\n const options = {\n imodel: this._imodel,\n rulesetOrId: HILITE_RULESET,\n descriptor,\n };\n const keyBatches = new Array<KeySet>();\n keys.forEachBatch(DEFAULT_KEYS_BATCH_SIZE, (batch: KeySet) => {\n keyBatches.push(batch);\n });\n return {\n options,\n keyBatches,\n };\n }\n\n private handleTransientKeys(selection: Readonly<KeySet>) {\n // need to create a new set without transients\n const transientIds = new Array<Id64String>();\n const keys = new KeySet();\n keys.add(selection, (key: Key) => {\n if (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) {\n transientIds.push(key.id);\n return false;\n }\n return true;\n });\n return {\n transientIds,\n keys,\n };\n }\n}\n\nconst CONTENT_SET_PAGE_SIZE = 1000;\n\nconst isModelRecord = (rec: Item) => rec.extendedData && rec.extendedData.isModel;\n\nconst isSubCategoryRecord = (rec: Item) => rec.extendedData && rec.extendedData.isSubCategory;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ISelectionProvider.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/ISelectionProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { KeySet } from \"@itwin/presentation-common\";\r\nimport { SelectionChangeEvent } from \"./SelectionChangeEvent\";\r\n\r\n/**\r\n * Selection provider interface which provides main selection and sub-selection.\r\n * @public\r\n */\r\nexport interface ISelectionProvider {\r\n /** An event that's fired when selection changes */\r\n selectionChange: SelectionChangeEvent;\r\n\r\n /** Get the selection stored in the provider.\r\n * @param imodel iModel connection which the selection is associated with.\r\n * @param level Level of the selection (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n */\r\n getSelection(imodel: IModelConnection, level: number): Readonly<KeySet>;\r\n}\r\n"]}
1
+ {"version":3,"file":"ISelectionProvider.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/ISelectionProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { SelectionChangeEvent } from \"./SelectionChangeEvent\";\n\n/**\n * Selection provider interface which provides main selection and sub-selection.\n * @public\n */\nexport interface ISelectionProvider {\n /** An event that's fired when selection changes */\n selectionChange: SelectionChangeEvent;\n\n /** Get the selection stored in the provider.\n * @param imodel iModel connection which the selection is associated with.\n * @param level Level of the selection (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\n */\n getSelection(imodel: IModelConnection, level: number): Readonly<KeySet>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAW9C;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,OAAiC;CAAG;AAE9E;;;GAGG;AACH,MAAM,CAAN,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B,0BAA0B;IAC1B,2DAAG,CAAA;IAEH,8BAA8B;IAC9B,iEAAM,CAAA;IAEN,8BAA8B;IAC9B,mEAAO,CAAA;IAEP,6BAA6B;IAC7B,+DAAK,CAAA;AACP,CAAC,EAZW,mBAAmB,KAAnB,mBAAmB,QAY9B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { BeEvent } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { KeySet } from \"@itwin/presentation-common\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\n\r\n/**\r\n * An interface for selection change listeners.\r\n * @public\r\n */\r\nexport declare type SelectionChangesListener = (args: SelectionChangeEventArgs, provider: ISelectionProvider) => void;\r\n\r\n/**\r\n * An event broadcasted on selection changes\r\n * @public\r\n */\r\nexport class SelectionChangeEvent extends BeEvent<SelectionChangesListener> {}\r\n\r\n/**\r\n * The type of selection change\r\n * @public\r\n */\r\nexport enum SelectionChangeType {\r\n /** Added to selection. */\r\n Add,\r\n\r\n /** Removed from selection. */\r\n Remove,\r\n\r\n /** Selection was replaced. */\r\n Replace,\r\n\r\n /** Selection was cleared. */\r\n Clear,\r\n}\r\n\r\n/**\r\n * The event object that's sent when the selection changes.\r\n * @public\r\n */\r\nexport interface SelectionChangeEventArgs {\r\n /** The name of the selection source which caused the selection change. */\r\n source: string;\r\n\r\n /** Level of the selection. See [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels). */\r\n level: number;\r\n\r\n /** The selection change type. */\r\n changeType: SelectionChangeType;\r\n\r\n /** Set of keys affected by this selection change event. */\r\n keys: Readonly<KeySet>;\r\n\r\n /** iModel connection with which the selection is associated with. */\r\n imodel: IModelConnection;\r\n\r\n /** The timestamp of when the selection change happened */\r\n timestamp: Date;\r\n\r\n /** Id of the ruleset associated with the selection change. */\r\n rulesetId?: string;\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionChangeEvent.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionChangeEvent.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAW9C;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,OAAiC;CAAG;AAE9E;;;GAGG;AACH,MAAM,CAAN,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B,0BAA0B;IAC1B,2DAAG,CAAA;IAEH,8BAA8B;IAC9B,iEAAM,CAAA;IAEN,8BAA8B;IAC9B,mEAAO,CAAA;IAEP,6BAA6B;IAC7B,+DAAK,CAAA;AACP,CAAC,EAZW,mBAAmB,KAAnB,mBAAmB,QAY9B","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { KeySet } from \"@itwin/presentation-common\";\nimport { ISelectionProvider } from \"./ISelectionProvider\";\n\n/**\n * An interface for selection change listeners.\n * @public\n */\nexport declare type SelectionChangesListener = (args: SelectionChangeEventArgs, provider: ISelectionProvider) => void;\n\n/**\n * An event broadcasted on selection changes\n * @public\n */\nexport class SelectionChangeEvent extends BeEvent<SelectionChangesListener> {}\n\n/**\n * The type of selection change\n * @public\n */\nexport enum SelectionChangeType {\n /** Added to selection. */\n Add,\n\n /** Removed from selection. */\n Remove,\n\n /** Selection was replaced. */\n Replace,\n\n /** Selection was cleared. */\n Clear,\n}\n\n/**\n * The event object that's sent when the selection changes.\n * @public\n */\nexport interface SelectionChangeEventArgs {\n /** The name of the selection source which caused the selection change. */\n source: string;\n\n /** Level of the selection. See [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels). */\n level: number;\n\n /** The selection change type. */\n changeType: SelectionChangeType;\n\n /** Set of keys affected by this selection change event. */\n keys: Readonly<KeySet>;\n\n /** iModel connection with which the selection is associated with. */\n imodel: IModelConnection;\n\n /** The timestamp of when the selection change happened */\n timestamp: Date;\n\n /** Id of the ruleset associated with the selection change. */\n rulesetId?: string;\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AAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5F,CAAC;IAED;;;OAGG;IACI,cAAc,CAAC,QAAgB,CAAC;QACrC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACpF,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { DisposableList, IDisposable } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { Keys, KeySet } from \"@itwin/presentation-common\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\nimport { SelectionChangeEventArgs, SelectionChangesListener } from \"./SelectionChangeEvent\";\r\nimport { SelectionManager } from \"./SelectionManager\";\r\n\r\n/**\r\n * Properties for creating a `SelectionHandler` instance.\r\n * @public\r\n */\r\nexport interface SelectionHandlerProps {\r\n /** SelectionManager used to store overall selection. */\r\n manager: SelectionManager;\r\n /** iModel connection the selection changes will be associated with. */\r\n imodel: IModelConnection;\r\n /**\r\n * Name of the selection handler. This is an identifier of what caused the\r\n * selection to change, set as `SelectionChangeEventArgs.source` when firing\r\n * selection change events. `SelectionHandler.shouldHandle` uses `name` to filter\r\n * events that it doesn't need to handle.\r\n */\r\n name: string;\r\n /**\r\n * ID of presentation ruleset used by the component using this handler. The ID is set as\r\n * `SelectionChangeEventArgs.rulesetId` when making selection changes and event\r\n * listeners can use or ignore this information.\r\n */\r\n rulesetId?: string;\r\n /** Callback function called when selection changes. */\r\n onSelect?: SelectionChangesListener;\r\n}\r\n\r\n/**\r\n * A class that handles selection changes and helps to change\r\n * internal the selection state.\r\n *\r\n * @public\r\n */\r\nexport class SelectionHandler implements IDisposable {\r\n private _inSelect: boolean;\r\n private _disposables: DisposableList;\r\n\r\n /** Selection manager used by this handler to manage selection */\r\n public readonly manager: SelectionManager;\r\n /** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */\r\n public name: string;\r\n /** iModel whose selection is being handled */\r\n public imodel: IModelConnection;\r\n /**\r\n * Id of a ruleset selection changes will be associated with.\r\n * @see `SelectionHandlerProps.rulesetId`\r\n */\r\n public rulesetId?: string;\r\n /** Callback function called when selection changes */\r\n public onSelect?: SelectionChangesListener;\r\n\r\n /**\r\n * Constructor.\r\n */\r\n constructor(props: SelectionHandlerProps) {\r\n this._inSelect = false;\r\n this.manager = props.manager;\r\n this._disposables = new DisposableList();\r\n this.name = props.name;\r\n this.rulesetId = props.rulesetId;\r\n this.imodel = props.imodel;\r\n this.onSelect = props.onSelect;\r\n this._disposables.add(this.manager.selectionChange.addListener(this.onSelectionChanged));\r\n }\r\n\r\n /**\r\n * Destructor. Must be called before disposing this object to make sure it cleans\r\n * up correctly.\r\n */\r\n public dispose(): void {\r\n this._disposables.dispose();\r\n }\r\n\r\n /**\r\n * Called when the selection changes. Handles this callback by first checking whether\r\n * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`\r\n */\r\n protected onSelectionChanged = (evt: SelectionChangeEventArgs, provider: ISelectionProvider): void => {\r\n if (!this.onSelect || !this.shouldHandle(evt)) {\r\n return;\r\n }\r\n\r\n this._inSelect = true;\r\n this.onSelect(evt, provider);\r\n this._inSelect = false;\r\n };\r\n\r\n /** Called to check whether the event should be handled by this handler */\r\n protected shouldHandle(evt: SelectionChangeEventArgs): boolean {\r\n if (this.name === evt.source) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Get selection levels for the imodel managed by this handler */\r\n public getSelectionLevels(): number[] {\r\n return this.manager.getSelectionLevels(this.imodel);\r\n }\r\n\r\n /**\r\n * Get selection for the imodel managed by this handler.\r\n * @param level Level of the selection to get. Defaults to 0.\r\n */\r\n public getSelection(level?: number): Readonly<KeySet> {\r\n return this.manager.getSelection(this.imodel, level);\r\n }\r\n\r\n /**\r\n * Add to selection.\r\n * @param keys The keys to add to selection.\r\n * @param level Level of the selection.\r\n */\r\n public addToSelection(keys: Keys, level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.addToSelection(this.name, this.imodel, keys, level, this.rulesetId);\r\n }\r\n\r\n /**\r\n * Remove from selection.\r\n * @param keys The keys to remove from selection.\r\n * @param level Level of the selection.\r\n */\r\n public removeFromSelection(keys: Keys, level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.removeFromSelection(this.name, this.imodel, keys, level, this.rulesetId);\r\n }\r\n\r\n /**\r\n * Change selection.\r\n * @param keys The keys indicating the new selection.\r\n * @param level Level of the selection.\r\n */\r\n public replaceSelection(keys: Keys, level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.replaceSelection(this.name, this.imodel, keys, level, this.rulesetId);\r\n }\r\n\r\n /**\r\n * Clear selection.\r\n * @param level Level of the selection.\r\n */\r\n public clearSelection(level: number = 0): void {\r\n if (this._inSelect) {\r\n return;\r\n }\r\n\r\n return this.manager.clearSelection(this.name, this.imodel, level, this.rulesetId);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionHandler.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAe,MAAM,qBAAqB,CAAC;AAiClE;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAkB3B;;OAEG;IACH,YAAY,KAA4B;QAmBxC;;;WAGG;QACO,uBAAkB,GAAG,CAAC,GAA6B,EAAE,QAA4B,EAAQ,EAAE;Y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------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { DisposableList, IDisposable } from \"@itwin/core-bentley\";\nimport { IModelConnection } from \"@itwin/core-frontend\";\nimport { Keys, KeySet } from \"@itwin/presentation-common\";\nimport { ISelectionProvider } from \"./ISelectionProvider\";\nimport { SelectionChangeEventArgs, SelectionChangesListener } from \"./SelectionChangeEvent\";\nimport { SelectionManager } from \"./SelectionManager\";\n\n/**\n * Properties for creating a `SelectionHandler` instance.\n * @public\n */\nexport interface SelectionHandlerProps {\n /** SelectionManager used to store overall selection. */\n manager: SelectionManager;\n /** iModel connection the selection changes will be associated with. */\n imodel: IModelConnection;\n /**\n * Name of the selection handler. This is an identifier of what caused the\n * selection to change, set as `SelectionChangeEventArgs.source` when firing\n * selection change events. `SelectionHandler.shouldHandle` uses `name` to filter\n * events that it doesn't need to handle.\n */\n name: string;\n /**\n * ID of presentation ruleset used by the component using this handler. The ID is set as\n * `SelectionChangeEventArgs.rulesetId` when making selection changes and event\n * listeners can use or ignore this information.\n */\n rulesetId?: string;\n /** Callback function called when selection changes. */\n onSelect?: SelectionChangesListener;\n}\n\n/**\n * A class that handles selection changes and helps to change\n * internal the selection state.\n *\n * @public\n */\nexport class SelectionHandler implements IDisposable {\n private _inSelect: boolean;\n private _disposables: DisposableList;\n\n /** Selection manager used by this handler to manage selection */\n public readonly manager: SelectionManager;\n /** Name that's used as `SelectionChangeEventArgs.source` when making selection changes */\n public name: string;\n /** iModel whose selection is being handled */\n public imodel: IModelConnection;\n /**\n * Id of a ruleset selection changes will be associated with.\n * @see `SelectionHandlerProps.rulesetId`\n */\n public rulesetId?: string;\n /** Callback function called when selection changes */\n public onSelect?: SelectionChangesListener;\n\n /**\n * Constructor.\n */\n constructor(props: SelectionHandlerProps) {\n this._inSelect = false;\n this.manager = props.manager;\n this._disposables = new DisposableList();\n this.name = props.name;\n this.rulesetId = props.rulesetId;\n this.imodel = props.imodel;\n this.onSelect = props.onSelect;\n this._disposables.add(this.manager.selectionChange.addListener(this.onSelectionChanged));\n }\n\n /**\n * Destructor. Must be called before disposing this object to make sure it cleans\n * up correctly.\n */\n public dispose(): void {\n this._disposables.dispose();\n }\n\n /**\n * Called when the selection changes. Handles this callback by first checking whether\n * the event should be handled at all (using the `shouldHandle` method) and then calling `onSelect`\n */\n protected onSelectionChanged = (evt: SelectionChangeEventArgs, provider: ISelectionProvider): void => {\n if (!this.onSelect || !this.shouldHandle(evt)) {\n return;\n }\n\n this._inSelect = true;\n this.onSelect(evt, provider);\n this._inSelect = false;\n };\n\n /** Called to check whether the event should be handled by this handler */\n protected shouldHandle(evt: SelectionChangeEventArgs): boolean {\n if (this.name === evt.source) {\n return false;\n }\n return true;\n }\n\n /** Get selection levels for the imodel managed by this handler */\n public getSelectionLevels(): number[] {\n return this.manager.getSelectionLevels(this.imodel);\n }\n\n /**\n * Get selection for the imodel managed by this handler.\n * @param level Level of the selection to get. Defaults to 0.\n */\n public getSelection(level?: number): Readonly<KeySet> {\n return this.manager.getSelection(this.imodel, level);\n }\n\n /**\n * Add to selection.\n * @param keys The keys to add to selection.\n * @param level Level of the selection.\n */\n public addToSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.addToSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Remove from selection.\n * @param keys The keys to remove from selection.\n * @param level Level of the selection.\n */\n public removeFromSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.removeFromSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Change selection.\n * @param keys The keys indicating the new selection.\n * @param level Level of the selection.\n */\n public replaceSelection(keys: Keys, level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.replaceSelection(this.name, this.imodel, keys, level, this.rulesetId);\n }\n\n /**\n * Clear selection.\n * @param level Level of the selection.\n */\n public clearSelection(level: number = 0): void {\n if (this._inSelect) {\n return;\n }\n\n return this.manager.clearSelection(this.name, this.imodel, level, this.rulesetId);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,uBAAuB;IACvB,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Helper class for working with selection.\r\n * @public\r\n */\r\nexport class SelectionHelper {\r\n // istanbul ignore next\r\n private constructor() {}\r\n\r\n /**\r\n * Re-map the given keyset for selection. This means all instance node keys get converted\r\n * to instance keys, because in that case we want to select instances instead of nodes. All\r\n * other types of keys ar left as is.\r\n */\r\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\r\n const result = new Array<Key>();\r\n keys.forEach((key: Key) => {\r\n if (Key.isNodeKey(key)) {\r\n if (NodeKey.isInstancesNodeKey(key)) {\r\n result.push(...key.instanceKeys);\r\n } else {\r\n result.push(key);\r\n }\r\n } else {\r\n result.push(key);\r\n }\r\n });\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAQ,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,eAAe;IAC1B,uBAAuB;IACvB,gBAAuB,CAAC;IAExB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvB,IAAI,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;gBACnC,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module UnifiedSelection\n */\n\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\n\n/**\n * Helper class for working with selection.\n * @public\n */\nexport class SelectionHelper {\n // istanbul ignore next\n private constructor() {}\n\n /**\n * Re-map the given keyset for selection. This means all instance node keys get converted\n * to instance keys, because in that case we want to select instances instead of nodes. All\n * other types of keys ar left as is.\n */\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\n const result = new Array<Key>();\n keys.forEach((key: Key) => {\n if (Key.isNodeKey(key)) {\n if (NodeKey.isInstancesNodeKey(key)) {\n result.push(...key.instanceKeys);\n } else {\n result.push(key);\n }\n } else {\n result.push(key);\n }\n });\n return result;\n }\n}\n"]}
@@ -21,13 +21,21 @@ export interface SelectionManagerProps {
21
21
  * and maintains storage.
22
22
  */
23
23
  selectionStorage?: SelectionStorage;
24
+ /**
25
+ * An optional function that returns a key for the given iModel. The key is what "glues" iModel selection
26
+ * changes made in `selectionStorage`, where iModels are identified by key, and `SelectionManager`, where
27
+ * iModels are specified as `IModelConnection`.
28
+ *
29
+ * If not provided, [IModelConnection.key]($core-frontend) or [IModelConnection.name]($core-frontend) is used.
30
+ */
31
+ imodelKeyFactory?: (imodel: IModelConnection) => string;
24
32
  }
25
33
  /**
26
34
  * The selection manager which stores the overall selection.
27
35
  * @public
28
36
  */
29
37
  export declare class SelectionManager implements ISelectionProvider {
30
- private _selectionStorage;
38
+ private _imodelKeyFactory;
31
39
  private _imodelToolSelectionSyncHandlers;
32
40
  private _hiliteSetProviders;
33
41
  private _ownsStorage;
@@ -36,6 +44,11 @@ export declare class SelectionManager implements ISelectionProvider {
36
44
  private _selectionChanges;
37
45
  private _selectionEventsSubscription;
38
46
  private _listeners;
47
+ /**
48
+ * Underlying selection storage used by this selection manager. Ideally, consumers should use
49
+ * the storage directly instead of using this manager to manipulate selection.
50
+ */
51
+ readonly selectionStorage: SelectionStorage;
39
52
  /** An event which gets broadcasted on selection changes */
40
53
  readonly selectionChange: SelectionChangeEvent;
41
54
  /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAQ,OAAO,EAAa,WAAW,EAAS,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAA4C,MAAM,sBAAsB,CAAC;AAClG,OAAO,EAAoD,IAAI,EAAE,MAAM,EAAW,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC1J,OAAO,EAKL,gBAAgB,EAIjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAiD,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAE7F;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,oGAAoG;IACpG,MAAM,EAAE,sBAAsB,CAAC;IAC/B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AAED;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,kBAAkB;IACzD,OAAO,CAAC,iBAAiB,CAAmB;IAC5C,OAAO,CAAC,gCAAgC,CAA+F;IACvI,OAAO,CAAC,mBAAmB,CAAkD;IAC7E,OAAO,CAAC,YAAY,CAAU;IAE9B,OAAO,CAAC,aAAa,CAAuC;IAC5D,OAAO,CAAC,iBAAiB,CAAiC;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C,uCAAuC,CAAa;IAC5D,OAAO,CAAC,cAAc,CAA2B;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;gBAEV,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB;IAMxE,OAAO;IAId,+BAA+B;IAC/B,IAAW,aAAa,gBAEvB;IAED,OAAO,CAAC,sBAAsB,CA4D5B;CACH"}
1
+ {"version":3,"file":"SelectionManager.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAQ,OAAO,EAAa,WAAW,EAAS,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAA2D,MAAM,sBAAsB,CAAC;AACjH,OAAO,EAAoD,IAAI,EAAE,MAAM,EAAW,cAAc,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC1J,OAAO,EAKL,gBAAgB,EAIjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAAqB,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAiD,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAA6B,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAE7F;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,oGAAoG;IACpG,MAAM,EAAE,sBAAsB,CAAC;IAE/B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,MAAM,CAAC;CACzD;AAED;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,kBAAkB;IACzD,OAAO,CAAC,iBAAiB,CAAuC;IAChE,OAAO,CAAC,gCAAgC,CAA+F;IACvI,OAAO,CAAC,mBAAmB,CAAkD;IAC7E,OAAO,CAAC,Y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BAAyB,YAAW,WAAW;IAC1D,OAAO,CAAC,oBAAoB,CAAU;IACtC,OAAO,CAAC,iBAAiB,CAAmB;IAC5C,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,uCAAuC,CAAa;IAC5D,OAAO,CAAC,cAAc,CAA2B;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;gBAEV,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB;IAMxE,OAAO;IAId,+BAA+B;IAC/B,IAAW,aAAa,gBAEvB;IAED,OAAO,CAAC,sBAAsB,CAwD5B;CACH"}
@@ -5,6 +5,12 @@
5
5
  /** @packageDocumentation
6
6
  * @module UnifiedSelection
7
7
  */
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _ScopedSelectionChanger_instances, _ScopedSelectionChanger_computeSelection;
8
14
  import { defer, EMPTY, mergeMap, of, Subject, takeUntil, tap } from "rxjs";
9
15
  import { Id64, using } from "@itwin/core-bentley";
10
16
  import { IModelConnection, SelectionSetEventType } from "@itwin/core-frontend";
@@ -25,18 +31,19 @@ export class SelectionManager {
25
31
  constructor(props) {
26
32
  this._imodelToolSelectionSyncHandlers = new Map();
27
33
  this._hiliteSetProviders = new Map();
28
- this._knownIModels = new Map();
34
+ this._knownIModels = new Set();
29
35
  this._currentSelection = new CurrentSelectionStorage();
30
36
  this._selectionChanges = new Subject();
31
37
  this._listeners = [];
32
38
  this.selectionChange = new SelectionChangeEvent();
33
39
  this.scopes = props.scopes;
34
- this._selectionStorage = props.selectionStorage ?? createStorage();
40
+ this.selectionStorage = props.selectionStorage ?? createStorage();
41
+ this._imodelKeyFactory = props.imodelKeyFactory ?? ((imodel) => (imodel.key.length ? imodel.key : imodel.name));
35
42
  this._ownsStorage = props.selectionStorage === undefined;
36
- this._selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
43
+ this.selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));
37
44
  this._selectionEventsSubscription = this.streamSelectionEvents();
38
45
  this._listeners.push(IModelConnection.onOpen.addListener((imodel) => {
39
- this._knownIModels.set(imodel.key, imodel);
46
+ this._knownIModels.add(imodel);
40
47
  }));
41
48
  this._listeners.push(IModelConnection.onClose.addListener((imodel) => {
42
49
  this.onConnectionClose(imodel);
@@ -47,12 +54,13 @@ export class SelectionManager {
47
54
  this._listeners.forEach((dispose) => dispose());
48
55
  }
49
56
  onConnectionClose(imodel) {
57
+ const imodelKey = this._imodelKeyFactory(imodel);
50
58
  this._hiliteSetProviders.delete(imodel);
51
- this._knownIModels.delete(imodel.key);
52
- this._currentSelection.clear(imodel.key);
59
+ this._knownIModels.delete(imodel);
60
+ this._currentSelection.clear(imodelKey);
53
61
  if (this._ownsStorage) {
54
62
  this.clearSelection("Connection Close Event", imodel);
55
- this._selectionStorage.clearStorage({ iModelKey: imodel.key });
63
+ this.selectionStorage.clearStorage({ imodelKey });
56
64
  }
57
65
  }
58
66
  /** @internal */
@@ -101,7 +109,8 @@ export class SelectionManager {
101
109
  }
102
110
  /** Get the selection levels currently stored in this manager for the specified imodel */
103
111
  getSelectionLevels(imodel) {
104
- return this._selectionStorage.getSelectionLevels({ iModelKey: imodel.key });
112
+ const imodelKey = this._imodelKeyFactory(imodel);
113
+ return this.selectionStorage.getSelectionLevels({ imodelKey });
105
114
  }
106
115
  /**
107
116
  * Get the selection currently stored in this manager
@@ -111,39 +120,39 @@ export class SelectionManager {
111
120
  * latest selection after changes.
112
121
  */
113
122
  getSelection(imodel, level = 0) {
114
- return this._currentSelection.getSelection(imodel.key, level);
123
+ const imodelKey = this._imodelKeyFactory(imodel);
124
+ return this._currentSelection.getSelection(imodelKey, level);
115
125
  }
116
126
  handleEvent(evt) {
117
- if (!this._knownIModels.has(evt.imodel.key)) {
118
- this._knownIModels.set(evt.imodel.key, evt.imodel);
119
- }
127
+ const imodelKey = this._imodelKeyFactory(evt.imodel);
128
+ this._knownIModels.add(evt.imodel);
120
129
  switch (evt.changeType) {
121
130
  case SelectionChangeType.Add:
122
- this._selectionStorage.addToSelection({
123
- iModelKey: evt.imodel.key,
131
+ this.selectionStorage.addToSelection({
132
+ imodelKey,
124
133
  source: evt.source,
125
134
  level: evt.level,
126
135
  selectables: keysToSelectable(evt.imodel, evt.keys),
127
136
  });
128
137
  break;
129
138
  case SelectionChangeType.Remove:
130
- this._selectionStorage.removeFromSelection({
131
- iModelKey: evt.imodel.key,
139
+ this.selectionStorage.removeFromSelection({
140
+ imodelKey,
132
141
  source: evt.source,
133
142
  level: evt.level,
134
143
  selectables: keysToSelectable(evt.imodel, evt.keys),
135
144
  });
136
145
  break;
137
146
  case SelectionChangeType.Replace:
138
- this._selectionStorage.replaceSelection({
139
- iModelKey: evt.imodel.key,
147
+ this.selectionStorage.replaceSelection({
148
+ imodelKey,
140
149
  source: evt.source,
141
150
  level: evt.level,
142
151
  selectables: keysToSelectable(evt.imodel, evt.keys),
143
152
  });
144
153
  break;
145
154
  case SelectionChangeType.Clear:
146
- this._selectionStorage.clearSelection({ iModelKey: evt.imodel.key, source: evt.source, level: evt.level });
155
+ this.selectionStorage.clearSelection({ imodelKey, source: evt.source, level: evt.level });
147
156
  break;
148
157
  }
149
158
  }
@@ -290,9 +299,9 @@ export class SelectionManager {
290
299
  streamSelectionEvents() {
291
300
  return this._selectionChanges
292
301
  .pipe(mergeMap((args) => {
293
- const currentSelectables = this._selectionStorage.getSelection({ iModelKey: args.imodelKey, level: args.level });
302
+ const currentSelectables = this.selectionStorage.getSelection({ imodelKey: args.imodelKey, level: args.level });
294
303
  return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(mergeMap(({ level, changedSelection }) => {
295
- const imodel = this._knownIModels.get(args.imodelKey);
304
+ const imodel = findIModel(this._knownIModels, this._imodelKeyFactory, args.imodelKey);
296
305
  // istanbul ignore if
297
306
  if (!imodel) {
298
307
  return EMPTY;
@@ -314,6 +323,14 @@ export class SelectionManager {
314
323
  });
315
324
  }
316
325
  }
326
+ function findIModel(set, imodelKeyFactory, key) {
327
+ for (const imodel of set) {
328
+ if (imodelKeyFactory(imodel) === key) {
329
+ return imodel;
330
+ }
331
+ }
332
+ return undefined;
333
+ }
317
334
  /** @internal */
318
335
  export class ToolSelectionSyncHandler {
319
336
  constructor(imodel, logicalSelection) {
@@ -335,13 +352,13 @@ export class ToolSelectionSyncHandler {
335
352
  let ids;
336
353
  switch (ev.type) {
337
354
  case SelectionSetEventType.Add:
338
- ids = ev.added;
355
+ ids = ev.additions;
339
356
  break;
340
357
  case SelectionSetEventType.Replace:
341
- ids = ev.set.elements;
358
+ ids = ev.set.active;
342
359
  break;
343
360
  default:
344
- ids = ev.removed;
361
+ ids = ev.removals;
345
362
  break;
346
363
  }
347
364
  // we're always using scoped selection changer even if the scope is set to "element" - that
@@ -349,22 +366,19 @@ export class ToolSelectionSyncHandler {
349
366
  // we can't because otherwise our keys compare fails (presentation components load data with
350
367
  // concrete classes)
351
368
  const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));
352
- // we know what to do immediately on `clear` events
353
- if (SelectionSetEventType.Clear === ev.type) {
354
- await changer.clear(selectionLevel);
355
- return;
356
- }
357
- const parsedIds = parseIds(ids);
358
369
  await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {
359
370
  switch (ev.type) {
360
371
  case SelectionSetEventType.Add:
361
- await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);
372
+ await changer.add(ids, selectionLevel);
362
373
  break;
363
374
  case SelectionSetEventType.Replace:
364
- await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);
375
+ await changer.replace(ids, selectionLevel);
365
376
  break;
366
377
  case SelectionSetEventType.Remove:
367
- await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);
378
+ await changer.remove(ids, selectionLevel);
379
+ break;
380
+ case SelectionSetEventType.Clear:
381
+ await changer.clear(selectionLevel);
368
382
  break;
369
383
  }
370
384
  });
@@ -381,7 +395,7 @@ export class ToolSelectionSyncHandler {
381
395
  return this._asyncsTracker.pendingAsyncs;
382
396
  }
383
397
  }
384
- const parseIds = (ids) => {
398
+ const parseElementIds = (ids) => {
385
399
  let allPersistent = true;
386
400
  let allTransient = true;
387
401
  for (const id of Id64.iterable(ids)) {
@@ -416,14 +430,14 @@ const parseIds = (ids) => {
416
430
  }
417
431
  return { persistent: persistentElementIds, transient: transientElementIds };
418
432
  };
419
- function addTransientKeys(transientIds, keys) {
420
- for (const id of Id64.iterable(transientIds)) {
421
- keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });
433
+ function addKeys(target, className, ids) {
434
+ for (const id of Id64.iterable(ids)) {
435
+ target.add({ className, id });
422
436
  }
423
437
  }
424
- /** @internal */
425
438
  class ScopedSelectionChanger {
426
439
  constructor(name, imodel, manager, scope) {
440
+ _ScopedSelectionChanger_instances.add(this);
427
441
  this.name = name;
428
442
  this.imodel = imodel;
429
443
  this.manager = manager;
@@ -432,22 +446,34 @@ class ScopedSelectionChanger {
432
446
  async clear(level) {
433
447
  this.manager.clearSelection(this.name, this.imodel, level);
434
448
  }
435
- async add(transientIds, persistentIds, level) {
436
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
437
- addTransientKeys(transientIds, keys);
449
+ async add(ids, level) {
450
+ const keys = await __classPrivateFieldGet(this, _ScopedSelectionChanger_instances, "m", _ScopedSelectionChanger_computeSelection).call(this, ids);
438
451
  this.manager.addToSelection(this.name, this.imodel, keys, level);
439
452
  }
440
- async remove(transientIds, persistentIds, level) {
441
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
442
- addTransientKeys(transientIds, keys);
453
+ async remove(ids, level) {
454
+ const keys = await __classPrivateFieldGet(this, _ScopedSelectionChanger_instances, "m", _ScopedSelectionChanger_computeSelection).call(this, ids);
443
455
  this.manager.removeFromSelection(this.name, this.imodel, keys, level);
444
456
  }
445
- async replace(transientIds, persistentIds, level) {
446
- const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);
447
- addTransientKeys(transientIds, keys);
457
+ async replace(ids, level) {
458
+ const keys = await __classPrivateFieldGet(this, _ScopedSelectionChanger_instances, "m", _ScopedSelectionChanger_computeSelection).call(this, ids);
448
459
  this.manager.replaceSelection(this.name, this.imodel, keys, level);
449
460
  }
450
461
  }
462
+ _ScopedSelectionChanger_instances = new WeakSet(), _ScopedSelectionChanger_computeSelection = async function _ScopedSelectionChanger_computeSelection(ids) {
463
+ let keys = new KeySet();
464
+ if (ids.elements) {
465
+ const { persistent, transient } = parseElementIds(ids.elements);
466
+ keys = await this.manager.scopes.computeSelection(this.imodel, persistent, this.scope);
467
+ addKeys(keys, TRANSIENT_ELEMENT_CLASSNAME, transient);
468
+ }
469
+ if (ids.models) {
470
+ addKeys(keys, "BisCore.Model", ids.models);
471
+ }
472
+ if (ids.subcategories) {
473
+ addKeys(keys, "BisCore.SubCategory", ids.subcategories);
474
+ }
475
+ return keys;
476
+ };
451
477
  /** Stores current selection in `KeySet` format per iModel. */
452
478
  class CurrentSelectionStorage {
453
479
  constructor() {