@itwin/presentation-frontend 5.0.0-dev.2 → 5.0.0-dev.20
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.
- package/CHANGELOG.md +18 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +4 -4
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +2 -2
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +0 -2
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +5 -7
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +0 -2
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +4 -6
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/package.json +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAAqG;AACrG,sDAAmF;AACnF,wDAAkG;AAClG,oEAA0J;AAC1J,gEAQkC;AAClC,kDAA+C;AAC/C,2DAAmE;AAEnE,iEAA6G;AAC7G,qEAA6F;AAgB7F;;;GAGG;AACH,MAAa,gBAAgB;IAkB3B;;OAEG;IACH,YAAY,KAA4B;QAnBhC,qCAAgC,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,CAAC;AAED,SAAS,aAAa,CAAC,IAAgC;IACrD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK;YACR,OAAO,0CAAmB,CAAC,GAAG,CAAC;QACjC,KAAK,QAAQ;YACX,OAAO,0CAAmB,CAAC,MAAM,CAAC;QACpC,KAAK,SAAS;YACZ,OAAO,0CAAmB,CAAC,OAAO,CAAC;QACrC,KAAK,OAAO;YACV,OAAO,0CAAmB,CAAC,KAAK,CAAC;IACrC,CAAC;AACH,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 { defer, EMPTY, mergeMap, Observable, of, Subject, Subscription, takeUntil, tap } from \"rxjs\";\r\nimport { Id64, Id64Arg, Id64Array, IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection, SelectionSetEvent, SelectionSetEventType } from \"@itwin/core-frontend\";\r\nimport { AsyncTasksTracker, BaseNodeKey, InstanceKey, Key, Keys, KeySet, NodeKey, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\nimport {\r\n createStorage,\r\n CustomSelectable,\r\n Selectable,\r\n Selectables,\r\n SelectionStorage,\r\n StorageSelectionChangeEventArgs,\r\n StorageSelectionChangeType,\r\n} from \"@itwin/unified-selection\";\r\nimport { Presentation } from \"../Presentation\";\r\nimport { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\nimport { SelectionChangeEvent, SelectionChangeEventArgs, SelectionChangeType } from \"./SelectionChangeEvent\";\r\nimport { createSelectionScopeProps, SelectionScopesManager } from \"./SelectionScopesManager\";\r\n\r\n/**\r\n * Properties for creating [[SelectionManager]].\r\n * @public\r\n */\r\nexport interface SelectionManagerProps {\r\n /** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n scopes: SelectionScopesManager;\r\n /**\r\n * Custom unified selection storage to be used by [[SelectionManager]]. If not provided [[SelectionManager]] creates\r\n * and maintains storage.\r\n */\r\n selectionStorage?: SelectionStorage;\r\n}\r\n\r\n/**\r\n * The selection manager which stores the overall selection.\r\n * @public\r\n */\r\nexport class SelectionManager implements ISelectionProvider {\r\n private _selectionStorage: SelectionStorage;\r\n private _imodelToolSelectionSyncHandlers = new Map<IModelConnection, { requestorsCount: number; handler: ToolSelectionSyncHandler }>();\r\n private _hiliteSetProviders = new Map<IModelConnection, HiliteSetProvider>();\r\n private _ownsStorage: boolean;\r\n\r\n private _knownIModels = new Map<string, IModelConnection>();\r\n private _currentSelection = new CurrentSelectionStorage();\r\n private _selectionChanges = new Subject<StorageSelectionChangeEventArgs>();\r\n private _selectionEventsSubscription: Subscription;\r\n private _listeners: Array<() => void> = [];\r\n\r\n /** An event which gets broadcasted on selection changes */\r\n public readonly selectionChange: SelectionChangeEvent;\r\n\r\n /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n public readonly scopes: SelectionScopesManager;\r\n\r\n /**\r\n * Creates an instance of SelectionManager.\r\n */\r\n constructor(props: SelectionManagerProps) {\r\n this.selectionChange = new SelectionChangeEvent();\r\n this.scopes = props.scopes;\r\n this._selectionStorage = props.selectionStorage ?? createStorage();\r\n this._ownsStorage = props.selectionStorage === undefined;\r\n this._selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));\r\n this._selectionEventsSubscription = this.streamSelectionEvents();\r\n this._listeners.push(\r\n IModelConnection.onOpen.addListener((imodel) => {\r\n this._knownIModels.set(imodel.key, imodel);\r\n }),\r\n );\r\n this._listeners.push(\r\n IModelConnection.onClose.addListener((imodel: IModelConnection) => {\r\n this.onConnectionClose(imodel);\r\n }),\r\n );\r\n }\r\n\r\n public dispose() {\r\n this._selectionEventsSubscription.unsubscribe();\r\n this._listeners.forEach((dispose) => dispose());\r\n }\r\n\r\n private onConnectionClose(imodel: IModelConnection): void {\r\n this._hiliteSetProviders.delete(imodel);\r\n this._knownIModels.delete(imodel.key);\r\n this._currentSelection.clear(imodel.key);\r\n if (this._ownsStorage) {\r\n this.clearSelection(\"Connection Close Event\", imodel);\r\n this._selectionStorage.clearStorage({ iModelKey: imodel.key });\r\n }\r\n }\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getToolSelectionSyncHandler(imodel: IModelConnection) {\r\n return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;\r\n }\r\n\r\n /**\r\n * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).\r\n */\r\n public setSyncWithIModelToolSelection(imodel: IModelConnection, sync = true) {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (sync) {\r\n if (!registration || registration.requestorsCount === 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { requestorsCount: 1, handler: new ToolSelectionSyncHandler(imodel, this) });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount: registration.requestorsCount + 1 });\r\n }\r\n } else {\r\n if (registration && registration.requestorsCount > 0) {\r\n const requestorsCount = registration.requestorsCount - 1;\r\n if (requestorsCount > 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.delete(imodel);\r\n registration.handler.dispose();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Temporarily suspends tool selection synchronization until the returned `IDisposable`\r\n * is disposed.\r\n */\r\n public suspendIModelToolSelectionSync(imodel: IModelConnection): IDisposable {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (!registration) {\r\n return { dispose: () => {} };\r\n }\r\n\r\n const wasSuspended = registration.handler.isSuspended;\r\n registration.handler.isSuspended = true;\r\n return { dispose: () => (registration.handler.isSuspended = wasSuspended) };\r\n }\r\n\r\n /** Get the selection levels currently stored in this manager for the specified imodel */\r\n public getSelectionLevels(imodel: IModelConnection): number[] {\r\n return this._selectionStorage.getSelectionLevels({ iModelKey: imodel.key });\r\n }\r\n\r\n /**\r\n * Get the selection currently stored in this manager\r\n *\r\n * @note Calling immediately after `add*`|`replace*`|`remove*`|`clear*` method call does not guarantee\r\n * that returned `KeySet` will include latest changes. Listen for `selectionChange` event to get the\r\n * latest selection after changes.\r\n */\r\n public getSelection(imodel: IModelConnection, level: number = 0): Readonly<KeySet> {\r\n return this._currentSelection.getSelection(imodel.key, level);\r\n }\r\n\r\n private handleEvent(evt: SelectionChangeEventArgs): void {\r\n if (!this._knownIModels.has(evt.imodel.key)) {\r\n this._knownIModels.set(evt.imodel.key, evt.imodel);\r\n }\r\n\r\n switch (evt.changeType) {\r\n case SelectionChangeType.Add:\r\n this._selectionStorage.addToSelection({\r\n iModelKey: evt.imodel.key,\r\n source: evt.source,\r\n level: evt.level,\r\n selectables: keysToSelectable(evt.imodel, evt.keys),\r\n });\r\n break;\r\n case SelectionChangeType.Remove:\r\n this._selectionStorage.removeFromSelection({\r\n iModelKey: evt.imodel.key,\r\n source: evt.source,\r\n level: evt.level,\r\n selectables: keysToSelectable(evt.imodel, evt.keys),\r\n });\r\n break;\r\n case SelectionChangeType.Replace:\r\n this._selectionStorage.replaceSelection({\r\n iModelKey: evt.imodel.key,\r\n source: evt.source,\r\n level: evt.level,\r\n selectables: keysToSelectable(evt.imodel, evt.keys),\r\n });\r\n break;\r\n case SelectionChangeType.Clear:\r\n this._selectionStorage.clearSelection({ iModelKey: evt.imodel.key, source: evt.source, level: evt.level });\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Add keys to the selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public addToSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Add,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to remove\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public removeFromSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Remove,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Replace current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public replaceSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Replace,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Clear current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public clearSelection(source: string, imodel: IModelConnection, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Clear,\r\n keys: new KeySet(),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Add keys to selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to add\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async addToSelectionWithScope(\r\n source: string,\r\n imodel: IModelConnection,\r\n ids: Id64Arg,\r\n scope: SelectionScopeProps | SelectionScope | string,\r\n level: number = 0,\r\n rulesetId?: string,\r\n ): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.addToSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to remove\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async removeFromSelectionWithScope(\r\n source: string,\r\n imodel: IModelConnection,\r\n ids: Id64Arg,\r\n scope: SelectionScopeProps | SelectionScope | string,\r\n level: number = 0,\r\n rulesetId?: string,\r\n ): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.removeFromSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Replace current selection with keys after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to replace with\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async replaceSelectionWithScope(\r\n source: string,\r\n imodel: IModelConnection,\r\n ids: Id64Arg,\r\n scope: SelectionScopeProps | SelectionScope | string,\r\n level: number = 0,\r\n rulesetId?: string,\r\n ): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.replaceSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Get the current hilite set for the specified imodel\r\n * @public\r\n */\r\n public async getHiliteSet(imodel: IModelConnection): Promise<HiliteSet> {\r\n return this.getHiliteSetProvider(imodel).getHiliteSet(this.getSelection(imodel));\r\n }\r\n\r\n /**\r\n * Get the current hilite set iterator for the specified imodel.\r\n * @public\r\n */\r\n public getHiliteSetIterator(imodel: IModelConnection) {\r\n return this.getHiliteSetProvider(imodel).getHiliteSetIterator(this.getSelection(imodel));\r\n }\r\n\r\n private getHiliteSetProvider(imodel: IModelConnection) {\r\n let provider = this._hiliteSetProviders.get(imodel);\r\n if (!provider) {\r\n provider = HiliteSetProvider.create({ imodel });\r\n this._hiliteSetProviders.set(imodel, provider);\r\n }\r\n return provider;\r\n }\r\n\r\n private streamSelectionEvents() {\r\n return this._selectionChanges\r\n .pipe(\r\n mergeMap((args) => {\r\n const currentSelectables = this._selectionStorage.getSelection({ iModelKey: args.iModelKey, level: args.level });\r\n return this._currentSelection.computeSelection(args.iModelKey, args.level, currentSelectables, args.selectables).pipe(\r\n mergeMap(({ level, changedSelection }): Observable<SelectionChangeEventArgs> => {\r\n const imodel = this._knownIModels.get(args.iModelKey);\r\n // istanbul ignore if\r\n if (!imodel) {\r\n return EMPTY;\r\n }\r\n return of({\r\n imodel,\r\n keys: changedSelection,\r\n level,\r\n source: args.source,\r\n timestamp: args.timestamp,\r\n changeType: getChangeType(args.changeType),\r\n });\r\n }),\r\n );\r\n }),\r\n )\r\n .subscribe({\r\n next: (args) => {\r\n this.selectionChange.raiseEvent(args, this);\r\n },\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\r\n\r\n/** @internal */\r\nexport class ToolSelectionSyncHandler implements IDisposable {\r\n private _selectionSourceName = \"Tool\";\r\n private _logicalSelection: SelectionManager;\r\n private _imodel: IModelConnection;\r\n private _imodelToolSelectionListenerDisposeFunc: () => void;\r\n private _asyncsTracker = new AsyncTasksTracker();\r\n public isSuspended?: boolean;\r\n\r\n public constructor(imodel: IModelConnection, logicalSelection: SelectionManager) {\r\n this._imodel = imodel;\r\n this._logicalSelection = logicalSelection;\r\n this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);\r\n }\r\n\r\n public dispose() {\r\n this._imodelToolSelectionListenerDisposeFunc();\r\n }\r\n\r\n /** note: used only it tests */\r\n public get pendingAsyncs() {\r\n return this._asyncsTracker.pendingAsyncs;\r\n }\r\n\r\n private onToolSelectionChanged = async (ev: SelectionSetEvent): Promise<void> => {\r\n // ignore selection change event if the handler is suspended\r\n if (this.isSuspended) {\r\n return;\r\n }\r\n\r\n // this component only cares about its own imodel\r\n const imodel = ev.set.iModel;\r\n if (imodel !== this._imodel) {\r\n return;\r\n }\r\n\r\n // determine the level of selection changes\r\n // wip: may want to allow selecting at different levels?\r\n const selectionLevel = 0;\r\n\r\n let ids: Id64Arg;\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n ids = ev.added;\r\n break;\r\n case SelectionSetEventType.Replace:\r\n ids = ev.set.elements;\r\n break;\r\n default:\r\n ids = ev.removed;\r\n break;\r\n }\r\n\r\n // we're always using scoped selection changer even if the scope is set to \"element\" - that\r\n // makes sure we're adding to selection keys with concrete classes and not \"BisCore:Element\", which\r\n // we can't because otherwise our keys compare fails (presentation components load data with\r\n // concrete classes)\r\n const changer = new ScopedSelectionChanger(\r\n this._selectionSourceName,\r\n this._imodel,\r\n this._logicalSelection,\r\n createSelectionScopeProps(this._logicalSelection.scopes.activeScope),\r\n );\r\n\r\n // we know what to do immediately on `clear` events\r\n if (SelectionSetEventType.Clear === ev.type) {\r\n await changer.clear(selectionLevel);\r\n return;\r\n }\r\n\r\n const parsedIds = parseIds(ids);\r\n await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Replace:\r\n await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Remove:\r\n await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n }\r\n });\r\n };\r\n}\r\n\r\nconst parseIds = (ids: Id64Arg): { persistent: Id64Arg; transient: Id64Arg } => {\r\n let allPersistent = true;\r\n let allTransient = true;\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id)) {\r\n allPersistent = false;\r\n } else {\r\n allTransient = false;\r\n }\r\n\r\n if (!allPersistent && !allTransient) {\r\n break;\r\n }\r\n }\r\n\r\n // avoid making a copy if ids are only persistent or only transient\r\n if (allPersistent) {\r\n return { persistent: ids, transient: [] };\r\n } else if (allTransient) {\r\n return { persistent: [], transient: ids };\r\n }\r\n\r\n // if `ids` contain mixed ids, we have to copy.. use Array instead of\r\n // a Set for performance\r\n const persistentElementIds: Id64Array = [];\r\n const transientElementIds: Id64Array = [];\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id)) {\r\n transientElementIds.push(id);\r\n } else {\r\n persistentElementIds.push(id);\r\n }\r\n }\r\n\r\n return { persistent: persistentElementIds, transient: transientElementIds };\r\n};\r\n\r\nfunction addTransientKeys(transientIds: Id64Arg, keys: KeySet): void {\r\n for (const id of Id64.iterable(transientIds)) {\r\n keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });\r\n }\r\n}\r\n\r\n/** @internal */\r\nclass ScopedSelectionChanger {\r\n public readonly name: string;\r\n public readonly imodel: IModelConnection;\r\n public readonly manager: SelectionManager;\r\n public readonly scope: SelectionScopeProps | SelectionScope | string;\r\n public constructor(name: string, imodel: IModelConnection, manager: SelectionManager, scope: SelectionScopeProps | SelectionScope | string) {\r\n this.name = name;\r\n this.imodel = imodel;\r\n this.manager = manager;\r\n this.scope = scope;\r\n }\r\n public async clear(level: number): Promise<void> {\r\n this.manager.clearSelection(this.name, this.imodel, level);\r\n }\r\n public async add(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.addToSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async remove(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.removeFromSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async replace(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.replaceSelection(this.name, this.imodel, keys, level);\r\n }\r\n}\r\n\r\n/** Stores current selection in `KeySet` format per iModel. */\r\nclass CurrentSelectionStorage {\r\n private _currentSelection = new Map<string, IModelSelectionStorage>();\r\n\r\n private getCurrentSelectionStorage(imodelKey: string) {\r\n let storage = this._currentSelection.get(imodelKey);\r\n if (!storage) {\r\n storage = new IModelSelectionStorage();\r\n this._currentSelection.set(imodelKey, storage);\r\n }\r\n return storage;\r\n }\r\n\r\n public getSelection(imodelKey: string, level: number) {\r\n return this.getCurrentSelectionStorage(imodelKey).getSelection(level);\r\n }\r\n\r\n public clear(imodelKey: string) {\r\n this._currentSelection.delete(imodelKey);\r\n }\r\n\r\n public computeSelection(imodelKey: string, level: number, currSelectables: Selectables, changedSelectables: Selectables) {\r\n return this.getCurrentSelectionStorage(imodelKey).computeSelection(level, currSelectables, changedSelectables);\r\n }\r\n}\r\n\r\ninterface StorageEntry {\r\n value: KeySet;\r\n ongoingComputationDisposers: Set<Subject<void>>;\r\n}\r\n\r\n/**\r\n * Computes and stores current selection in `KeySet` format.\r\n * It always stores result of latest resolved call to `computeSelection`.\r\n */\r\nclass IModelSelectionStorage {\r\n private _currentSelection = new Map<number, StorageEntry>();\r\n\r\n public getSelection(level: number): KeySet {\r\n let entry = this._currentSelection.get(level);\r\n if (!entry) {\r\n entry = { value: new KeySet(), ongoingComputationDisposers: new Set() };\r\n this._currentSelection.set(level, entry);\r\n }\r\n return entry.value;\r\n }\r\n\r\n private clearSelections(level: number) {\r\n const clearedLevels = [];\r\n for (const [storedLevel] of this._currentSelection.entries()) {\r\n if (storedLevel > level) {\r\n clearedLevels.push(storedLevel);\r\n }\r\n }\r\n clearedLevels.forEach((storedLevel) => {\r\n const entry = this._currentSelection.get(storedLevel);\r\n // istanbul ignore if\r\n if (!entry) {\r\n return;\r\n }\r\n\r\n for (const disposer of entry.ongoingComputationDisposers) {\r\n disposer.next();\r\n }\r\n this._currentSelection.delete(storedLevel);\r\n });\r\n }\r\n\r\n private addDisposer(level: number, disposer: Subject<void>) {\r\n const entry = this._currentSelection.get(level);\r\n if (!entry) {\r\n this._currentSelection.set(level, { value: new KeySet(), ongoingComputationDisposers: new Set([disposer]) });\r\n return;\r\n }\r\n entry.ongoingComputationDisposers.add(disposer);\r\n }\r\n\r\n private setSelection(level: number, keys: KeySet, disposer: Subject<void>) {\r\n const currEntry = this._currentSelection.get(level);\r\n // istanbul ignore else\r\n if (currEntry) {\r\n currEntry.ongoingComputationDisposers.delete(disposer);\r\n }\r\n this._currentSelection.set(level, {\r\n value: keys,\r\n ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* istanbul ignore next */ new Set(),\r\n });\r\n }\r\n\r\n public computeSelection(level: number, currSelectables: Selectables, changedSelectables: Selectables) {\r\n this.clearSelections(level);\r\n\r\n const prevComputationsDisposers = [...(this._currentSelection.get(level)?.ongoingComputationDisposers ?? [])];\r\n const currDisposer = new Subject<void>();\r\n this.addDisposer(level, currDisposer);\r\n\r\n return defer(async () => {\r\n const convertedSelectables: SelectableKeys[] = [];\r\n const [current, changed] = await Promise.all([\r\n selectablesToKeys(currSelectables, convertedSelectables),\r\n selectablesToKeys(changedSelectables, convertedSelectables),\r\n ]);\r\n\r\n const currentSelection = new KeySet([...current.keys, ...current.selectableKeys.flatMap((selectable) => selectable.keys)]);\r\n const changedSelection = new KeySet([...changed.keys, ...changed.selectableKeys.flatMap((selectable) => selectable.keys)]);\r\n\r\n return {\r\n level,\r\n currentSelection,\r\n changedSelection,\r\n };\r\n }).pipe(\r\n takeUntil(currDisposer),\r\n tap({\r\n next: (val) => {\r\n prevComputationsDisposers.forEach((disposer) => disposer.next());\r\n this.setSelection(val.level, val.currentSelection, currDisposer);\r\n },\r\n }),\r\n );\r\n }\r\n}\r\n\r\nfunction keysToSelectable(imodel: IModelConnection, keys: Readonly<KeySet>) {\r\n const selectables: Selectable[] = [];\r\n keys.forEach((key) => {\r\n if (\"id\" in key) {\r\n selectables.push(key);\r\n return;\r\n }\r\n\r\n const customSelectable: CustomSelectable = {\r\n identifier: key.pathFromRoot.join(\"/\"),\r\n data: key,\r\n loadInstanceKeys: () => createInstanceKeysIterator(imodel, key),\r\n };\r\n selectables.push(customSelectable);\r\n });\r\n return selectables;\r\n}\r\n\r\ninterface SelectableKeys {\r\n identifier: string;\r\n keys: Key[];\r\n}\r\n\r\nasync function selectablesToKeys(selectables: Selectables, convertedList: SelectableKeys[]) {\r\n const keys: Key[] = [];\r\n const selectableKeys: SelectableKeys[] = [];\r\n\r\n for (const [className, ids] of selectables.instanceKeys) {\r\n for (const id of ids) {\r\n keys.push({ id, className });\r\n }\r\n }\r\n\r\n for (const [_, selectable] of selectables.custom) {\r\n if (isNodeKey(selectable.data)) {\r\n selectableKeys.push({ identifier: selectable.identifier, keys: [selectable.data] });\r\n continue;\r\n }\r\n const converted = convertedList.find((con) => con.identifier === selectable.identifier);\r\n if (converted) {\r\n selectableKeys.push(converted);\r\n continue;\r\n }\r\n\r\n const newConverted: SelectableKeys = { identifier: selectable.identifier, keys: [] };\r\n convertedList.push(newConverted);\r\n for await (const instanceKey of selectable.loadInstanceKeys()) {\r\n newConverted.keys.push(instanceKey);\r\n }\r\n selectableKeys.push(newConverted);\r\n }\r\n\r\n return { keys, selectableKeys };\r\n}\r\n\r\nasync function* createInstanceKeysIterator(imodel: IModelConnection, nodeKey: NodeKey): AsyncIterableIterator<InstanceKey> {\r\n if (NodeKey.isInstancesNodeKey(nodeKey)) {\r\n for (const key of nodeKey.instanceKeys) {\r\n yield key;\r\n }\r\n return;\r\n }\r\n\r\n const content = await Presentation.presentation.getContentInstanceKeys({\r\n imodel,\r\n keys: new KeySet([nodeKey]),\r\n rulesetOrId: {\r\n id: \"grouped-instances\",\r\n rules: [\r\n {\r\n ruleType: \"Content\",\r\n specifications: [\r\n {\r\n specType: \"SelectedNodeInstances\",\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n });\r\n\r\n for await (const key of content.items()) {\r\n yield key;\r\n }\r\n}\r\n\r\nfunction isNodeKey(data: unknown): data is NodeKey {\r\n const key = data as BaseNodeKey;\r\n return key.pathFromRoot !== undefined && key.type !== undefined;\r\n}\r\n\r\nfunction getChangeType(type: StorageSelectionChangeType): SelectionChangeType {\r\n switch (type) {\r\n case \"add\":\r\n return SelectionChangeType.Add;\r\n case \"remove\":\r\n return SelectionChangeType.Remove;\r\n case \"replace\":\r\n return SelectionChangeType.Replace;\r\n case \"clear\":\r\n return SelectionChangeType.Clear;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"SelectionManager.js","sourceRoot":"","sources":["../../../../src/presentation-fr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,CAAC,KAAK,EAAE,EAAE,CAAC;QACxC,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,IAAa;IAC9B,MAAM,GAAG,GAAG,IAAmB,CAAC;IAChC,OAAO,GAAG,CAAC,YAAY,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC;AAClE,CAAC;AAED,SAAS,aAAa,CAAC,IAAgC;IACrD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,KAAK;YACR,OAAO,0CAAmB,CAAC,GAAG,CAAC;QACjC,KAAK,QAAQ;YACX,OAAO,0CAAmB,CAAC,MAAM,CAAC;QACpC,KAAK,SAAS;YACZ,OAAO,0CAAmB,CAAC,OAAO,CAAC;QACrC,KAAK,OAAO;YACV,OAAO,0CAAmB,CAAC,KAAK,CAAC;IACrC,CAAC;AACH,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 { defer, EMPTY, mergeMap, Observable, of, Subject, Subscription, takeUntil, tap } from \"rxjs\";\r\nimport { Id64, Id64Arg, Id64Array, IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection, SelectionSetEvent, SelectionSetEventType } from \"@itwin/core-frontend\";\r\nimport { AsyncTasksTracker, BaseNodeKey, InstanceKey, Key, Keys, KeySet, NodeKey, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\nimport {\r\n createStorage,\r\n CustomSelectable,\r\n Selectable,\r\n Selectables,\r\n SelectionStorage,\r\n StorageSelectionChangeEventArgs,\r\n StorageSelectionChangeType,\r\n TRANSIENT_ELEMENT_CLASSNAME,\r\n} from \"@itwin/unified-selection\";\r\nimport { Presentation } from \"../Presentation\";\r\nimport { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\nimport { SelectionChangeEvent, SelectionChangeEventArgs, SelectionChangeType } from \"./SelectionChangeEvent\";\r\nimport { createSelectionScopeProps, SelectionScopesManager } from \"./SelectionScopesManager\";\r\n\r\n/**\r\n * Properties for creating [[SelectionManager]].\r\n * @public\r\n */\r\nexport interface SelectionManagerProps {\r\n /** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n scopes: SelectionScopesManager;\r\n /**\r\n * Custom unified selection storage to be used by [[SelectionManager]]. If not provided [[SelectionManager]] creates\r\n * and maintains storage.\r\n */\r\n selectionStorage?: SelectionStorage;\r\n}\r\n\r\n/**\r\n * The selection manager which stores the overall selection.\r\n * @public\r\n */\r\nexport class SelectionManager implements ISelectionProvider {\r\n private _selectionStorage: SelectionStorage;\r\n private _imodelToolSelectionSyncHandlers = new Map<IModelConnection, { requestorsCount: number; handler: ToolSelectionSyncHandler }>();\r\n private _hiliteSetProviders = new Map<IModelConnection, HiliteSetProvider>();\r\n private _ownsStorage: boolean;\r\n\r\n private _knownIModels = new Map<string, IModelConnection>();\r\n private _currentSelection = new CurrentSelectionStorage();\r\n private _selectionChanges = new Subject<StorageSelectionChangeEventArgs>();\r\n private _selectionEventsSubscription: Subscription;\r\n private _listeners: Array<() => void> = [];\r\n\r\n /** An event which gets broadcasted on selection changes */\r\n public readonly selectionChange: SelectionChangeEvent;\r\n\r\n /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n public readonly scopes: SelectionScopesManager;\r\n\r\n /**\r\n * Creates an instance of SelectionManager.\r\n */\r\n constructor(props: SelectionManagerProps) {\r\n this.selectionChange = new SelectionChangeEvent();\r\n this.scopes = props.scopes;\r\n this._selectionStorage = props.selectionStorage ?? createStorage();\r\n this._ownsStorage = props.selectionStorage === undefined;\r\n this._selectionStorage.selectionChangeEvent.addListener((args) => this._selectionChanges.next(args));\r\n this._selectionEventsSubscription = this.streamSelectionEvents();\r\n this._listeners.push(\r\n IModelConnection.onOpen.addListener((imodel) => {\r\n this._knownIModels.set(imodel.key, imodel);\r\n }),\r\n );\r\n this._listeners.push(\r\n IModelConnection.onClose.addListener((imodel: IModelConnection) => {\r\n this.onConnectionClose(imodel);\r\n }),\r\n );\r\n }\r\n\r\n public dispose() {\r\n this._selectionEventsSubscription.unsubscribe();\r\n this._listeners.forEach((dispose) => dispose());\r\n }\r\n\r\n private onConnectionClose(imodel: IModelConnection): void {\r\n this._hiliteSetProviders.delete(imodel);\r\n this._knownIModels.delete(imodel.key);\r\n this._currentSelection.clear(imodel.key);\r\n if (this._ownsStorage) {\r\n this.clearSelection(\"Connection Close Event\", imodel);\r\n this._selectionStorage.clearStorage({ iModelKey: imodel.key });\r\n }\r\n }\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getToolSelectionSyncHandler(imodel: IModelConnection) {\r\n return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler;\r\n }\r\n\r\n /**\r\n * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).\r\n */\r\n public setSyncWithIModelToolSelection(imodel: IModelConnection, sync = true) {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (sync) {\r\n if (!registration || registration.requestorsCount === 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { requestorsCount: 1, handler: new ToolSelectionSyncHandler(imodel, this) });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount: registration.requestorsCount + 1 });\r\n }\r\n } else {\r\n if (registration && registration.requestorsCount > 0) {\r\n const requestorsCount = registration.requestorsCount - 1;\r\n if (requestorsCount > 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.delete(imodel);\r\n registration.handler.dispose();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Temporarily suspends tool selection synchronization until the returned `IDisposable`\r\n * is disposed.\r\n */\r\n public suspendIModelToolSelectionSync(imodel: IModelConnection): IDisposable {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (!registration) {\r\n return { dispose: () => {} };\r\n }\r\n\r\n const wasSuspended = registration.handler.isSuspended;\r\n registration.handler.isSuspended = true;\r\n return { dispose: () => (registration.handler.isSuspended = wasSuspended) };\r\n }\r\n\r\n /** Get the selection levels currently stored in this manager for the specified imodel */\r\n public getSelectionLevels(imodel: IModelConnection): number[] {\r\n return this._selectionStorage.getSelectionLevels({ iModelKey: imodel.key });\r\n }\r\n\r\n /**\r\n * Get the selection currently stored in this manager\r\n *\r\n * @note Calling immediately after `add*`|`replace*`|`remove*`|`clear*` method call does not guarantee\r\n * that returned `KeySet` will include latest changes. Listen for `selectionChange` event to get the\r\n * latest selection after changes.\r\n */\r\n public getSelection(imodel: IModelConnection, level: number = 0): Readonly<KeySet> {\r\n return this._currentSelection.getSelection(imodel.key, level);\r\n }\r\n\r\n private handleEvent(evt: SelectionChangeEventArgs): void {\r\n if (!this._knownIModels.has(evt.imodel.key)) {\r\n this._knownIModels.set(evt.imodel.key, evt.imodel);\r\n }\r\n\r\n switch (evt.changeType) {\r\n case SelectionChangeType.Add:\r\n this._selectionStorage.addToSelection({\r\n iModelKey: evt.imodel.key,\r\n source: evt.source,\r\n level: evt.level,\r\n selectables: keysToSelectable(evt.imodel, evt.keys),\r\n });\r\n break;\r\n case SelectionChangeType.Remove:\r\n this._selectionStorage.removeFromSelection({\r\n iModelKey: evt.imodel.key,\r\n source: evt.source,\r\n level: evt.level,\r\n selectables: keysToSelectable(evt.imodel, evt.keys),\r\n });\r\n break;\r\n case SelectionChangeType.Replace:\r\n this._selectionStorage.replaceSelection({\r\n iModelKey: evt.imodel.key,\r\n source: evt.source,\r\n level: evt.level,\r\n selectables: keysToSelectable(evt.imodel, evt.keys),\r\n });\r\n break;\r\n case SelectionChangeType.Clear:\r\n this._selectionStorage.clearSelection({ iModelKey: evt.imodel.key, source: evt.source, level: evt.level });\r\n break;\r\n }\r\n }\r\n\r\n /**\r\n * Add keys to the selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public addToSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Add,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to remove\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public removeFromSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Remove,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Replace current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public replaceSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Replace,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Clear current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public clearSelection(source: string, imodel: IModelConnection, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Clear,\r\n keys: new KeySet(),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Add keys to selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to add\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async addToSelectionWithScope(\r\n source: string,\r\n imodel: IModelConnection,\r\n ids: Id64Arg,\r\n scope: SelectionScopeProps | SelectionScope | string,\r\n level: number = 0,\r\n rulesetId?: string,\r\n ): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.addToSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to remove\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async removeFromSelectionWithScope(\r\n source: string,\r\n imodel: IModelConnection,\r\n ids: Id64Arg,\r\n scope: SelectionScopeProps | SelectionScope | string,\r\n level: number = 0,\r\n rulesetId?: string,\r\n ): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.removeFromSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Replace current selection with keys after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to replace with\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async replaceSelectionWithScope(\r\n source: string,\r\n imodel: IModelConnection,\r\n ids: Id64Arg,\r\n scope: SelectionScopeProps | SelectionScope | string,\r\n level: number = 0,\r\n rulesetId?: string,\r\n ): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.replaceSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Get the current hilite set for the specified imodel\r\n * @public\r\n */\r\n public async getHiliteSet(imodel: IModelConnection): Promise<HiliteSet> {\r\n return this.getHiliteSetProvider(imodel).getHiliteSet(this.getSelection(imodel));\r\n }\r\n\r\n /**\r\n * Get the current hilite set iterator for the specified imodel.\r\n * @public\r\n */\r\n public getHiliteSetIterator(imodel: IModelConnection) {\r\n return this.getHiliteSetProvider(imodel).getHiliteSetIterator(this.getSelection(imodel));\r\n }\r\n\r\n private getHiliteSetProvider(imodel: IModelConnection) {\r\n let provider = this._hiliteSetProviders.get(imodel);\r\n if (!provider) {\r\n provider = HiliteSetProvider.create({ imodel });\r\n this._hiliteSetProviders.set(imodel, provider);\r\n }\r\n return provider;\r\n }\r\n\r\n private streamSelectionEvents() {\r\n return this._selectionChanges\r\n .pipe(\r\n mergeMap((args) => {\r\n const currentSelectables = this._selectionStorage.getSelection({ iModelKey: args.imodelKey, level: args.level });\r\n return this._currentSelection.computeSelection(args.imodelKey, args.level, currentSelectables, args.selectables).pipe(\r\n mergeMap(({ level, changedSelection }): Observable<SelectionChangeEventArgs> => {\r\n const imodel = this._knownIModels.get(args.imodelKey);\r\n // istanbul ignore if\r\n if (!imodel) {\r\n return EMPTY;\r\n }\r\n return of({\r\n imodel,\r\n keys: changedSelection,\r\n level,\r\n source: args.source,\r\n timestamp: args.timestamp,\r\n changeType: getChangeType(args.changeType),\r\n });\r\n }),\r\n );\r\n }),\r\n )\r\n .subscribe({\r\n next: (args) => {\r\n this.selectionChange.raiseEvent(args, this);\r\n },\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class ToolSelectionSyncHandler implements IDisposable {\r\n private _selectionSourceName = \"Tool\";\r\n private _logicalSelection: SelectionManager;\r\n private _imodel: IModelConnection;\r\n private _imodelToolSelectionListenerDisposeFunc: () => void;\r\n private _asyncsTracker = new AsyncTasksTracker();\r\n public isSuspended?: boolean;\r\n\r\n public constructor(imodel: IModelConnection, logicalSelection: SelectionManager) {\r\n this._imodel = imodel;\r\n this._logicalSelection = logicalSelection;\r\n this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);\r\n }\r\n\r\n public dispose() {\r\n this._imodelToolSelectionListenerDisposeFunc();\r\n }\r\n\r\n /** note: used only it tests */\r\n public get pendingAsyncs() {\r\n return this._asyncsTracker.pendingAsyncs;\r\n }\r\n\r\n private onToolSelectionChanged = async (ev: SelectionSetEvent): Promise<void> => {\r\n // ignore selection change event if the handler is suspended\r\n if (this.isSuspended) {\r\n return;\r\n }\r\n\r\n // this component only cares about its own imodel\r\n const imodel = ev.set.iModel;\r\n if (imodel !== this._imodel) {\r\n return;\r\n }\r\n\r\n // determine the level of selection changes\r\n // wip: may want to allow selecting at different levels?\r\n const selectionLevel = 0;\r\n\r\n let ids: Id64Arg;\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n ids = ev.added;\r\n break;\r\n case SelectionSetEventType.Replace:\r\n ids = ev.set.elements;\r\n break;\r\n default:\r\n ids = ev.removed;\r\n break;\r\n }\r\n\r\n // we're always using scoped selection changer even if the scope is set to \"element\" - that\r\n // makes sure we're adding to selection keys with concrete classes and not \"BisCore:Element\", which\r\n // we can't because otherwise our keys compare fails (presentation components load data with\r\n // concrete classes)\r\n const changer = new ScopedSelectionChanger(\r\n this._selectionSourceName,\r\n this._imodel,\r\n this._logicalSelection,\r\n createSelectionScopeProps(this._logicalSelection.scopes.activeScope),\r\n );\r\n\r\n // we know what to do immediately on `clear` events\r\n if (SelectionSetEventType.Clear === ev.type) {\r\n await changer.clear(selectionLevel);\r\n return;\r\n }\r\n\r\n const parsedIds = parseIds(ids);\r\n await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Replace:\r\n await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Remove:\r\n await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n }\r\n });\r\n };\r\n}\r\n\r\nconst parseIds = (ids: Id64Arg): { persistent: Id64Arg; transient: Id64Arg } => {\r\n let allPersistent = true;\r\n let allTransient = true;\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id)) {\r\n allPersistent = false;\r\n } else {\r\n allTransient = false;\r\n }\r\n\r\n if (!allPersistent && !allTransient) {\r\n break;\r\n }\r\n }\r\n\r\n // avoid making a copy if ids are only persistent or only transient\r\n if (allPersistent) {\r\n return { persistent: ids, transient: [] };\r\n } else if (allTransient) {\r\n return { persistent: [], transient: ids };\r\n }\r\n\r\n // if `ids` contain mixed ids, we have to copy.. use Array instead of\r\n // a Set for performance\r\n const persistentElementIds: Id64Array = [];\r\n const transientElementIds: Id64Array = [];\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id)) {\r\n transientElementIds.push(id);\r\n } else {\r\n persistentElementIds.push(id);\r\n }\r\n }\r\n\r\n return { persistent: persistentElementIds, transient: transientElementIds };\r\n};\r\n\r\nfunction addTransientKeys(transientIds: Id64Arg, keys: KeySet): void {\r\n for (const id of Id64.iterable(transientIds)) {\r\n keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });\r\n }\r\n}\r\n\r\n/** @internal */\r\nclass ScopedSelectionChanger {\r\n public readonly name: string;\r\n public readonly imodel: IModelConnection;\r\n public readonly manager: SelectionManager;\r\n public readonly scope: SelectionScopeProps | SelectionScope | string;\r\n public constructor(name: string, imodel: IModelConnection, manager: SelectionManager, scope: SelectionScopeProps | SelectionScope | string) {\r\n this.name = name;\r\n this.imodel = imodel;\r\n this.manager = manager;\r\n this.scope = scope;\r\n }\r\n public async clear(level: number): Promise<void> {\r\n this.manager.clearSelection(this.name, this.imodel, level);\r\n }\r\n public async add(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.addToSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async remove(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.removeFromSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async replace(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.replaceSelection(this.name, this.imodel, keys, level);\r\n }\r\n}\r\n\r\n/** Stores current selection in `KeySet` format per iModel. */\r\nclass CurrentSelectionStorage {\r\n private _currentSelection = new Map<string, IModelSelectionStorage>();\r\n\r\n private getCurrentSelectionStorage(imodelKey: string) {\r\n let storage = this._currentSelection.get(imodelKey);\r\n if (!storage) {\r\n storage = new IModelSelectionStorage();\r\n this._currentSelection.set(imodelKey, storage);\r\n }\r\n return storage;\r\n }\r\n\r\n public getSelection(imodelKey: string, level: number) {\r\n return this.getCurrentSelectionStorage(imodelKey).getSelection(level);\r\n }\r\n\r\n public clear(imodelKey: string) {\r\n this._currentSelection.delete(imodelKey);\r\n }\r\n\r\n public computeSelection(imodelKey: string, level: number, currSelectables: Selectables, changedSelectables: Selectables) {\r\n return this.getCurrentSelectionStorage(imodelKey).computeSelection(level, currSelectables, changedSelectables);\r\n }\r\n}\r\n\r\ninterface StorageEntry {\r\n value: KeySet;\r\n ongoingComputationDisposers: Set<Subject<void>>;\r\n}\r\n\r\n/**\r\n * Computes and stores current selection in `KeySet` format.\r\n * It always stores result of latest resolved call to `computeSelection`.\r\n */\r\nclass IModelSelectionStorage {\r\n private _currentSelection = new Map<number, StorageEntry>();\r\n\r\n public getSelection(level: number): KeySet {\r\n let entry = this._currentSelection.get(level);\r\n if (!entry) {\r\n entry = { value: new KeySet(), ongoingComputationDisposers: new Set() };\r\n this._currentSelection.set(level, entry);\r\n }\r\n return entry.value;\r\n }\r\n\r\n private clearSelections(level: number) {\r\n const clearedLevels = [];\r\n for (const [storedLevel] of this._currentSelection.entries()) {\r\n if (storedLevel > level) {\r\n clearedLevels.push(storedLevel);\r\n }\r\n }\r\n clearedLevels.forEach((storedLevel) => {\r\n const entry = this._currentSelection.get(storedLevel);\r\n // istanbul ignore if\r\n if (!entry) {\r\n return;\r\n }\r\n\r\n for (const disposer of entry.ongoingComputationDisposers) {\r\n disposer.next();\r\n }\r\n this._currentSelection.delete(storedLevel);\r\n });\r\n }\r\n\r\n private addDisposer(level: number, disposer: Subject<void>) {\r\n const entry = this._currentSelection.get(level);\r\n if (!entry) {\r\n this._currentSelection.set(level, { value: new KeySet(), ongoingComputationDisposers: new Set([disposer]) });\r\n return;\r\n }\r\n entry.ongoingComputationDisposers.add(disposer);\r\n }\r\n\r\n private setSelection(level: number, keys: KeySet, disposer: Subject<void>) {\r\n const currEntry = this._currentSelection.get(level);\r\n // istanbul ignore else\r\n if (currEntry) {\r\n currEntry.ongoingComputationDisposers.delete(disposer);\r\n }\r\n this._currentSelection.set(level, {\r\n value: keys,\r\n ongoingComputationDisposers: currEntry?.ongoingComputationDisposers ?? /* istanbul ignore next */ new Set(),\r\n });\r\n }\r\n\r\n public computeSelection(level: number, currSelectables: Selectables, changedSelectables: Selectables) {\r\n this.clearSelections(level);\r\n\r\n const prevComputationsDisposers = [...(this._currentSelection.get(level)?.ongoingComputationDisposers ?? [])];\r\n const currDisposer = new Subject<void>();\r\n this.addDisposer(level, currDisposer);\r\n\r\n return defer(async () => {\r\n const convertedSelectables: SelectableKeys[] = [];\r\n const [current, changed] = await Promise.all([\r\n selectablesToKeys(currSelectables, convertedSelectables),\r\n selectablesToKeys(changedSelectables, convertedSelectables),\r\n ]);\r\n\r\n const currentSelection = new KeySet([...current.keys, ...current.selectableKeys.flatMap((selectable) => selectable.keys)]);\r\n const changedSelection = new KeySet([...changed.keys, ...changed.selectableKeys.flatMap((selectable) => selectable.keys)]);\r\n\r\n return {\r\n level,\r\n currentSelection,\r\n changedSelection,\r\n };\r\n }).pipe(\r\n takeUntil(currDisposer),\r\n tap({\r\n next: (val) => {\r\n prevComputationsDisposers.forEach((disposer) => disposer.next());\r\n this.setSelection(val.level, val.currentSelection, currDisposer);\r\n },\r\n }),\r\n );\r\n }\r\n}\r\n\r\nfunction keysToSelectable(imodel: IModelConnection, keys: Readonly<KeySet>) {\r\n const selectables: Selectable[] = [];\r\n keys.forEach((key) => {\r\n if (\"id\" in key) {\r\n selectables.push(key);\r\n return;\r\n }\r\n\r\n const customSelectable: CustomSelectable = {\r\n identifier: key.pathFromRoot.join(\"/\"),\r\n data: key,\r\n loadInstanceKeys: () => createInstanceKeysIterator(imodel, key),\r\n };\r\n selectables.push(customSelectable);\r\n });\r\n return selectables;\r\n}\r\n\r\ninterface SelectableKeys {\r\n identifier: string;\r\n keys: Key[];\r\n}\r\n\r\nasync function selectablesToKeys(selectables: Selectables, convertedList: SelectableKeys[]) {\r\n const keys: Key[] = [];\r\n const selectableKeys: SelectableKeys[] = [];\r\n\r\n for (const [className, ids] of selectables.instanceKeys) {\r\n for (const id of ids) {\r\n keys.push({ id, className });\r\n }\r\n }\r\n\r\n for (const [_, selectable] of selectables.custom) {\r\n if (isNodeKey(selectable.data)) {\r\n selectableKeys.push({ identifier: selectable.identifier, keys: [selectable.data] });\r\n continue;\r\n }\r\n const converted = convertedList.find((con) => con.identifier === selectable.identifier);\r\n if (converted) {\r\n selectableKeys.push(converted);\r\n continue;\r\n }\r\n\r\n const newConverted: SelectableKeys = { identifier: selectable.identifier, keys: [] };\r\n convertedList.push(newConverted);\r\n for await (const instanceKey of selectable.loadInstanceKeys()) {\r\n newConverted.keys.push(instanceKey);\r\n }\r\n selectableKeys.push(newConverted);\r\n }\r\n\r\n return { keys, selectableKeys };\r\n}\r\n\r\nasync function* createInstanceKeysIterator(imodel: IModelConnection, nodeKey: NodeKey): AsyncIterableIterator<InstanceKey> {\r\n if (NodeKey.isInstancesNodeKey(nodeKey)) {\r\n for (const key of nodeKey.instanceKeys) {\r\n yield key;\r\n }\r\n return;\r\n }\r\n\r\n const content = await Presentation.presentation.getContentInstanceKeys({\r\n imodel,\r\n keys: new KeySet([nodeKey]),\r\n rulesetOrId: {\r\n id: \"grouped-instances\",\r\n rules: [\r\n {\r\n ruleType: \"Content\",\r\n specifications: [\r\n {\r\n specType: \"SelectedNodeInstances\",\r\n },\r\n ],\r\n },\r\n ],\r\n },\r\n });\r\n\r\n for await (const key of content.items()) {\r\n yield key;\r\n }\r\n}\r\n\r\nfunction isNodeKey(data: unknown): data is NodeKey {\r\n const key = data as BaseNodeKey;\r\n return key.pathFromRoot !== undefined && key.type !== undefined;\r\n}\r\n\r\nfunction getChangeType(type: StorageSelectionChangeType): SelectionChangeType {\r\n switch (type) {\r\n case \"add\":\r\n return SelectionChangeType.Add;\r\n case \"remove\":\r\n return SelectionChangeType.Remove;\r\n case \"replace\":\r\n return SelectionChangeType.Replace;\r\n case \"clear\":\r\n return SelectionChangeType.Clear;\r\n }\r\n}\r\n"]}
|
|
@@ -12,8 +12,8 @@ import { IpcRequestsHandler } from "./IpcRequestsHandler";
|
|
|
12
12
|
import { FrontendLocalizationHelper } from "./LocalizationHelper";
|
|
13
13
|
import { RulesetManagerImpl } from "./RulesetManager";
|
|
14
14
|
import { RulesetVariablesManagerImpl } from "./RulesetVariablesManager";
|
|
15
|
-
import { TRANSIENT_ELEMENT_CLASSNAME } from "./selection/SelectionManager";
|
|
16
15
|
import { StreamedResponseGenerator } from "./StreamedResponseGenerator";
|
|
16
|
+
import { TRANSIENT_ELEMENT_CLASSNAME } from "@itwin/unified-selection";
|
|
17
17
|
/**
|
|
18
18
|
* Frontend Presentation manager which basically just forwards all calls to
|
|
19
19
|
* the backend implementation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAe,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAoB,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,EACL,sBAAsB,EAEtB,OAAO,EAEP,YAAY,EACZ,gBAAgB,EAEhB,6BAA6B,EAI7B,0BAA0B,EAC1B,UAAU,EAIV,iBAAiB,EAUjB,IAAI,EAEJ,GAAG,EACH,MAAM,EACN,yBAAyB,EAEzB,IAAI,EAEJ,eAAe,EAIf,qBAAqB,EACrB,kBAAkB,EAElB,eAAe,EACf,eAAe,EAGf,kBAAkB,GACnB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,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GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B,CAAC,EAAE,CAAC;QACjG,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;QACrB,kFAAkF;QAClF,4EAA4E;QAC5E,uBAAuB;QACvB,MAAM,WAAW,GACf,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B,CAAC;YACzE,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,aAAa,KAAK,2BAA2B,CAAC,CAAC;QAChF,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,KAAK,UAAU,OAAO,CAAI,IAAsB;IAC9C,MAAM,MAAM,GAAG,IAAI,KAAK,EAAK,CAAC;IAC9B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,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 Core\r\n */\r\n\r\nimport { BeEvent, CompressedId64Set, IDisposable, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport { IModelApp, IModelConnection, IpcApp } from \"@itwin/core-frontend\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n buildElementProperties,\r\n ClientDiagnosticsAttribute,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentFormatter,\r\n ContentInstanceKeysRequestOptions,\r\n ContentPropertyValueFormatter,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n ContentUpdateInfo,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n HierarchyUpdateInfo,\r\n InstanceKey,\r\n Item,\r\n ItemJSON,\r\n Key,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PageOptions,\r\n PresentationIpcEvents,\r\n RpcRequestsHandler,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SingleElementPropertiesRequestOptions,\r\n UpdateInfo,\r\n VariableValueTypes,\r\n} from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\nimport { FrontendLocalizationHelper } from \"./LocalizationHelper\";\r\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\r\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"./selection/SelectionManager\";\r\nimport { StreamedResponseGenerator } from \"./StreamedResponseGenerator\";\r\n\r\n/**\r\n * Data structure that describes IModel hierarchy change event arguments.\r\n * @public\r\n */\r\nexport interface IModelHierarchyChangeEventArgs {\r\n /** Id of ruleset that was used to create hierarchy. */\r\n rulesetId: string;\r\n /** Hierarchy changes info. */\r\n updateInfo: HierarchyUpdateInfo;\r\n /** Key of iModel that was used to create hierarchy. It matches [[IModelConnection.key]] property. */\r\n imodelKey: string;\r\n}\r\n\r\n/**\r\n * Data structure that describes iModel content change event arguments.\r\n * @public\r\n */\r\nexport interface IModelContentChangeEventArgs {\r\n /** Id of ruleset that was used to create content. */\r\n rulesetId: string;\r\n /** Content changes info. */\r\n updateInfo: ContentUpdateInfo;\r\n /** Key of iModel that was used to create content. It matches [[IModelConnection.key]] property. */\r\n imodelKey: string;\r\n}\r\n\r\n/**\r\n * Options for requests that can return multiple pages of items concurrently.\r\n * @public\r\n */\r\nexport type MultipleValuesRequestOptions = Paged<{\r\n /**\r\n * Max number of requests that should be made to the backend to fulfill the whole request.\r\n * `undefined` means no limit, so in that case all requests are sent at once.\r\n */\r\n maxParallelRequests?: number;\r\n\r\n /**\r\n * Size of a single batch when fetching data through multiple requests. If not set,\r\n * the fall back is requested page size. If the page size is not set, the backend\r\n * decides how many items to return.\r\n */\r\n batchSize?: number;\r\n}>;\r\n\r\n/**\r\n * Options for requests that retrieve nodes.\r\n * @public\r\n */\r\nexport type GetNodesRequestOptions = HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute;\r\n\r\n/**\r\n * Options for requests that retrieve content.\r\n * @public\r\n */\r\nexport type GetContentRequestOptions = ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> &\r\n ClientDiagnosticsAttribute;\r\n\r\n/**\r\n * Options for requests that retrieve distinct values.\r\n * @public\r\n */\r\nexport type GetDistinctValuesRequestOptions = DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> &\r\n ClientDiagnosticsAttribute;\r\n\r\n/**\r\n * Properties used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Sets the active locale to use when localizing presentation-related\r\n * strings. It can later be changed through [[PresentationManager]].\r\n */\r\n activeLocale?: string;\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. The value can later be changed through [[PresentationManager.activeUnitSystem]] setter or\r\n * overriden for each request through request parameters. If not set, `IModelApp.quantityFormatter.activeUnitSystem`\r\n * is used by default.\r\n *\r\n * @deprecated in 4.0. Use [IModelApp.quantityFormatter]($core-frontend) to set the active unit system.\r\n */\r\n activeUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * ID used to identify client that requests data. Generally, clients should\r\n * store this ID in their local storage so the ID can be reused across\r\n * sessions - this allows reusing some caches.\r\n *\r\n * Defaults to a unique GUID as a client id.\r\n */\r\n clientId?: string;\r\n\r\n /**\r\n * Timeout (in milliseconds) for how long we're going to wait for RPC request to be fulfilled before throwing\r\n * a timeout error.\r\n *\r\n * Defaults to 10 minutes.\r\n */\r\n requestTimeout?: number;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelConnection]($core-frontend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n */\r\n schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n *\r\n * @note Only has effect when frontend value formatting is enabled by supplying the `schemaContextProvider` prop.\r\n */\r\n defaultFormats?: FormatsMap;\r\n\r\n /** @internal */\r\n rpcRequestsHandler?: RpcRequestsHandler;\r\n\r\n /** @internal */\r\n ipcRequestsHandler?: IpcRequestsHandler;\r\n}\r\n\r\n/**\r\n * Frontend Presentation manager which basically just forwards all calls to\r\n * the backend implementation.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager implements IDisposable {\r\n private _requestsHandler: RpcRequestsHandler;\r\n private _rulesets: RulesetManager;\r\n private _localizationHelper: FrontendLocalizationHelper;\r\n private _explicitActiveUnitSystem: UnitSystemKey | undefined;\r\n private _rulesetVars: Map<string, RulesetVariablesManager>;\r\n private _clearEventListener?: () => void;\r\n private _schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\r\n private _defaultFormats?: FormatsMap;\r\n private _ipcRequestsHandler?: IpcRequestsHandler;\r\n\r\n /**\r\n * An event raised when hierarchies created using specific ruleset change\r\n */\r\n public onIModelHierarchyChanged = new BeEvent<(args: IModelHierarchyChangeEventArgs) => void>();\r\n\r\n /**\r\n * An event raised when content created using specific ruleset changes\r\n */\r\n public onIModelContentChanged = new BeEvent<(args: IModelContentChangeEventArgs) => void>();\r\n\r\n /**\r\n * Get / set active unit system used to format property values with units.\r\n *\r\n * @deprecated in 4.0. `IModelApp.quantityFormatter` should be used to get/set the active unit system. At the moment\r\n * [[PresentationManager]] allows overriding it, but returns `IModelApp.quantityFormatter.activeUnitSystem` if override\r\n * is not set.\r\n */\r\n public get activeUnitSystem(): UnitSystemKey {\r\n return this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem;\r\n }\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._explicitActiveUnitSystem = value;\r\n }\r\n\r\n private constructor(props?: PresentationManagerProps) {\r\n if (props) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this._explicitActiveUnitSystem = props.activeUnitSystem;\r\n }\r\n\r\n this._requestsHandler =\r\n props?.rpcRequestsHandler ?? new RpcRequestsHandler(props ? { clientId: props.clientId, timeout: props.requestTimeout } : undefined);\r\n this._rulesetVars = new Map<string, RulesetVariablesManager>();\r\n this._rulesets = RulesetManagerImpl.create();\r\n this._localizationHelper = new FrontendLocalizationHelper(props?.activeLocale);\r\n this._schemaContextProvider = props?.schemaContextProvider;\r\n this._defaultFormats = props?.defaultFormats;\r\n\r\n if (IpcApp.isValid) {\r\n // Ipc only works in ipc apps, so the `onUpdate` callback will only be called there.\r\n this._clearEventListener = IpcApp.addListener(PresentationIpcEvents.Update, this.onUpdate);\r\n this._ipcRequestsHandler = props?.ipcRequestsHandler ?? new IpcRequestsHandler(this._requestsHandler.clientId);\r\n }\r\n }\r\n\r\n /** Get / set active locale used for localizing presentation data */\r\n public get activeLocale(): string | undefined {\r\n return this._localizationHelper.locale;\r\n }\r\n public set activeLocale(locale: string | undefined) {\r\n this._localizationHelper.locale = locale;\r\n }\r\n\r\n public dispose() {\r\n if (this._clearEventListener) {\r\n this._clearEventListener();\r\n this._clearEventListener = undefined;\r\n }\r\n }\r\n\r\n private onUpdate = (_evt: Event, report: UpdateInfo) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.handleUpdateAsync(report);\r\n };\r\n\r\n /** @note This is only called in native apps after changes in iModels */\r\n private async handleUpdateAsync(report: UpdateInfo) {\r\n for (const imodelKey in report) {\r\n // istanbul ignore if\r\n if (!report.hasOwnProperty(imodelKey)) {\r\n continue;\r\n }\r\n\r\n const imodelReport = report[imodelKey];\r\n for (const rulesetId in imodelReport) {\r\n // istanbul ignore if\r\n if (!imodelReport.hasOwnProperty(rulesetId)) {\r\n continue;\r\n }\r\n\r\n const updateInfo = imodelReport[rulesetId];\r\n if (updateInfo.content) {\r\n this.onIModelContentChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.content, imodelKey });\r\n }\r\n if (updateInfo.hierarchy) {\r\n this.onIModelHierarchyChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.hierarchy, imodelKey });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Function that is called when a new IModelConnection is used to retrieve data.\r\n * @internal\r\n */\r\n public startIModelInitialization(_: IModelConnection) {}\r\n\r\n /**\r\n * Function that should be called to finish initialization that was started at [[PresentationManager.startIModelInitialization]].\r\n * Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.\r\n * @internal\r\n */\r\n public async ensureIModelInitialized(_: IModelConnection) {}\r\n\r\n /**\r\n * Create a new PresentationManager instance\r\n * @param props Optional properties used to configure the manager\r\n */\r\n public static create(props?: PresentationManagerProps) {\r\n return new PresentationManager(props);\r\n }\r\n\r\n /** @internal */\r\n public get rpcRequestsHandler() {\r\n return this._requestsHandler;\r\n }\r\n\r\n /** @internal */\r\n public get ipcRequestsHandler() {\r\n return this._ipcRequestsHandler;\r\n }\r\n\r\n /**\r\n * Get rulesets manager\r\n */\r\n public rulesets() {\r\n return this._rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get the vars manager for\r\n */\r\n public vars(rulesetId: string) {\r\n if (!this._rulesetVars.has(rulesetId)) {\r\n const varsManager = new RulesetVariablesManagerImpl(rulesetId, this._ipcRequestsHandler);\r\n this._rulesetVars.set(rulesetId, varsManager);\r\n }\r\n return this._rulesetVars.get(rulesetId)!;\r\n }\r\n\r\n private toRpcTokenOptions<TOptions extends { imodel: IModelConnection; locale?: string; unitSystem?: UnitSystemKey; rulesetVariables?: RulesetVariable[] }>(\r\n requestOptions: TOptions,\r\n ) {\r\n // 1. put default `locale` and `unitSystem`\r\n // 2. put all `requestOptions` members (if `locale` or `unitSystem` are set, they'll override the defaults put at #1)\r\n // 3. put `imodel` of type `IModelRpcProps` which overwrites the `imodel` from `requestOptions` put at #2\r\n const defaultOptions: Pick<TOptions, \"locale\" | \"unitSystem\"> = {};\r\n if (this.activeLocale) {\r\n defaultOptions.locale = this.activeLocale;\r\n }\r\n defaultOptions.unitSystem = this.activeUnitSystem; // eslint-disable-line @typescript-eslint/no-deprecated\r\n\r\n const { imodel, rulesetVariables, ...rpcRequestOptions } = requestOptions;\r\n return {\r\n ...defaultOptions,\r\n ...rpcRequestOptions,\r\n ...(rulesetVariables ? { rulesetVariables: rulesetVariables.map(RulesetVariable.toJSON) } : {}),\r\n imodel: imodel.getRpcProps(),\r\n };\r\n }\r\n\r\n private async addRulesetAndVariablesToOptions<TOptions extends { rulesetOrId: Ruleset | string; rulesetVariables?: RulesetVariable[] }>(options: TOptions) {\r\n const { rulesetOrId, rulesetVariables } = options;\r\n let foundRulesetOrId: Ruleset | string;\r\n if (typeof rulesetOrId === \"object\") {\r\n foundRulesetOrId = rulesetOrId;\r\n } else {\r\n const foundRuleset = await this._rulesets.get(rulesetOrId);\r\n foundRulesetOrId = foundRuleset ? foundRuleset.toJSON() : rulesetOrId;\r\n }\r\n const rulesetId = typeof foundRulesetOrId === \"object\" ? foundRulesetOrId.id : foundRulesetOrId;\r\n\r\n // All Id64Array variable values must be sorted for serialization to JSON to work. RulesetVariablesManager\r\n // sorts them before storing, so that part is taken care of, but we need to ensure that variables coming from\r\n // request options are also sorted.\r\n const variables = (rulesetVariables ?? []).map((variable) => {\r\n if (variable.type === VariableValueTypes.Id64Array) {\r\n return { ...variable, value: OrderedId64Iterable.sortArray(variable.value) };\r\n }\r\n return variable;\r\n });\r\n if (!this._ipcRequestsHandler) {\r\n // only need to add variables from variables manager if there's no IPC\r\n // handler - if there is one, the variables are already known by the backend\r\n variables.push(...this.vars(rulesetId).getAllVariables());\r\n }\r\n\r\n return { ...options, rulesetOrId: foundRulesetOrId, rulesetVariables: variables };\r\n }\r\n\r\n /** Returns an iterator that polls nodes asynchronously. */\r\n public async getNodesIterator(\r\n requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: AsyncIterableIterator<Node> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (paging) => {\r\n const result = await this._requestsHandler.getPagedNodes({ ...rpcOptions, paging });\r\n return {\r\n total: result.total,\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n items: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),\r\n };\r\n },\r\n });\r\n\r\n return generator.createAsyncIteratorResponse();\r\n }\r\n\r\n /**\r\n * Retrieves nodes\r\n * @deprecated in 4.5. Use [[getNodesIterator]] instead.\r\n */\r\n public async getNodes(requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions): Promise<Node[]> {\r\n const result = await this.getNodesIterator(requestOptions);\r\n return collect(result.items);\r\n }\r\n\r\n /** Retrieves nodes count. */\r\n public async getNodesCount(requestOptions: GetNodesRequestOptions): Promise<number> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n return this._requestsHandler.getNodesCount(rpcOptions);\r\n }\r\n\r\n /**\r\n * Retrieves total nodes count and a single page of nodes.\r\n * @deprecated in 4.5. Use [[getNodesIterator]] instead.\r\n */\r\n public async getNodesAndCount(requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions): Promise<{ count: number; nodes: Node[] }> {\r\n const result = await this.getNodesIterator(requestOptions);\r\n return {\r\n count: result.total,\r\n nodes: await collect(result.items),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor.\r\n * @public\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: HierarchyLevelDescriptorRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n try {\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await this._requestsHandler.getNodesDescriptor(rpcOptions);\r\n const descriptor = Descriptor.fromJSON(result);\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n } finally {\r\n await this.ensureIModelInitialized(requestOptions.imodel);\r\n }\r\n }\r\n\r\n /** Retrieves paths from root nodes to children nodes according to specified keys. Intersecting paths will be merged. */\r\n public async getNodePaths(\r\n requestOptions: FilterByInstancePathsHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await this._requestsHandler.getNodePaths(rpcOptions);\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return result.map(NodePathElement.fromJSON).map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /** Retrieves paths from root nodes to nodes containing filter text in their label. */\r\n public async getFilteredNodePaths(\r\n requestOptions: FilterByTextHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const result = await this._requestsHandler.getFilteredNodePaths(this.toRpcTokenOptions(options));\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return result.map(NodePathElement.fromJSON).map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(requestOptions: ContentSourcesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute): Promise<SelectClassInfo[]> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions(requestOptions);\r\n const result = await this._requestsHandler.getContentSources(rpcOptions);\r\n return SelectClassInfo.listFromCompressedJSON(result.sources, result.classesMap);\r\n }\r\n\r\n /** Retrieves the content descriptor which describes the content and can be used to customize it. */\r\n public async getContentDescriptor(\r\n requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n try {\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n });\r\n const result = await this._requestsHandler.getContentDescriptor(rpcOptions);\r\n const descriptor = Descriptor.fromJSON(result);\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n } finally {\r\n await this.ensureIModelInitialized(requestOptions.imodel);\r\n }\r\n }\r\n\r\n /** Retrieves overall content set size. */\r\n public async getContentSetSize(requestOptions: GetContentRequestOptions): Promise<number> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\r\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\r\n });\r\n return this._requestsHandler.getContentSetSize(rpcOptions);\r\n }\r\n\r\n private async getContentIteratorInternal(\r\n requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ descriptor: Descriptor; total: number; items: AsyncIterableIterator<Item> } | undefined> {\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const firstPageSize = options.batchSize ?? requestOptions.paging?.size;\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\r\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\r\n ...(firstPageSize ? { paging: { ...requestOptions.paging, size: firstPageSize } } : undefined),\r\n ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n let contentFormatter: ContentFormatter | undefined;\r\n if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);\r\n contentFormatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem,\r\n );\r\n }\r\n\r\n let descriptor = requestOptions.descriptor instanceof Descriptor ? requestOptions.descriptor : undefined;\r\n let firstPage: PagedResponse<ItemJSON> | undefined;\r\n if (!descriptor) {\r\n const firstPageResponse = await this._requestsHandler.getPagedContent(rpcOptions);\r\n if (!firstPageResponse?.descriptor || !firstPageResponse.contentSet) {\r\n return undefined;\r\n }\r\n descriptor = Descriptor.fromJSON(firstPageResponse?.descriptor);\r\n firstPage = firstPageResponse?.contentSet;\r\n }\r\n\r\n // istanbul ignore if\r\n if (!descriptor) {\r\n return undefined;\r\n }\r\n\r\n descriptor = this._localizationHelper.getLocalizedContentDescriptor(descriptor);\r\n\r\n const getPage = async (paging: Required<PageOptions>, requestIndex: number) => {\r\n let contentSet = requestIndex === 0 ? firstPage : undefined;\r\n contentSet ??= await this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging });\r\n\r\n let items = contentSet.items.map((x) => Item.fromJSON(x)).filter((x): x is Item => x !== undefined);\r\n if (contentFormatter) {\r\n items = await contentFormatter.formatContentItems(items, descriptor);\r\n }\r\n\r\n items = this._localizationHelper.getLocalizedContentItems(items);\r\n return {\r\n total: contentSet.total,\r\n items,\r\n };\r\n };\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: getPage,\r\n });\r\n\r\n return {\r\n ...(await generator.createAsyncIteratorResponse()),\r\n descriptor,\r\n };\r\n }\r\n\r\n /** Retrieves a content descriptor, item count and async generator for the items themselves. */\r\n public async getContentIterator(\r\n requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ descriptor: Descriptor; total: number; items: AsyncIterableIterator<Item> } | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const response = await this.getContentIteratorInternal(requestOptions);\r\n if (!response) {\r\n return undefined;\r\n }\r\n\r\n await this.ensureIModelInitialized(requestOptions.imodel);\r\n return response;\r\n }\r\n\r\n /**\r\n * Retrieves content which consists of a content descriptor and a page of records.\r\n * @deprecated in 4.5. Use [[getContentIterator]] instead.\r\n */\r\n public async getContent(requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions): Promise<Content | undefined> {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return (await this.getContentAndSize(requestOptions))?.content;\r\n }\r\n\r\n /**\r\n * Retrieves content set size and content which consists of a content descriptor and a page of records.\r\n * @deprecated in 4.5. Use [[getContentIterator]] instead.\r\n */\r\n public async getContentAndSize(\r\n requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ content: Content; size: number } | undefined> {\r\n const response = await this.getContentIterator(requestOptions);\r\n if (!response) {\r\n return undefined;\r\n }\r\n\r\n const { descriptor, total } = response;\r\n const items = await collect(response.items);\r\n return {\r\n content: new Content(descriptor, items),\r\n size: total,\r\n };\r\n }\r\n\r\n /** Returns an iterator that asynchronously polls distinct values of specific field from the content. */\r\n public async getDistinctValuesIterator(\r\n requestOptions: GetDistinctValuesRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: AsyncIterableIterator<DisplayValueGroup> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = {\r\n ...this.toRpcTokenOptions(options),\r\n descriptor: getDescriptorOverrides(options.descriptor),\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n };\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (paging) => {\r\n const response = await this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging });\r\n return {\r\n total: response.total,\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n items: response.items.map((x) => this._localizationHelper.getLocalizedDisplayValueGroup(DisplayValueGroup.fromJSON(x))),\r\n };\r\n },\r\n });\r\n\r\n return generator.createAsyncIteratorResponse();\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content.\r\n * @deprecated in 4.5. Use [[getDistinctValuesIterator]] instead.\r\n */\r\n public async getPagedDistinctValues(\r\n requestOptions: GetDistinctValuesRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n const result = await this.getDistinctValuesIterator(requestOptions);\r\n return {\r\n total: result.total,\r\n items: await collect(result.items),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: SingleElementPropertiesRequestOptions<IModelConnection, TParsedContent> & ClientDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const iter = await this.getContentIterator({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!iter || iter.total === 0) {\r\n return undefined;\r\n }\r\n return parser(iter.descriptor, (await iter.items.next()).value);\r\n }\r\n\r\n /**\r\n * Retrieves content item instance keys.\r\n * @public\r\n */\r\n public async getContentInstanceKeys(\r\n requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: () => AsyncGenerator<InstanceKey> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = {\r\n ...this.toRpcTokenOptions(options),\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n };\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (page) => {\r\n const keys = await this._requestsHandler.getContentInstanceKeys({ ...rpcOptions, paging: page });\r\n return {\r\n total: keys.total,\r\n items: keys.items.instanceKeys.reduce((instanceKeys, entry) => {\r\n for (const id of CompressedId64Set.iterable(entry[1])) {\r\n instanceKeys.push({ className: entry[0], id });\r\n }\r\n return instanceKeys;\r\n }, new Array<InstanceKey>()),\r\n };\r\n },\r\n });\r\n\r\n const { total, items } = await generator.createAsyncIteratorResponse();\r\n return {\r\n total,\r\n async *items() {\r\n yield* items;\r\n },\r\n };\r\n }\r\n\r\n /** Retrieves display label definition of specific item. */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: DisplayLabelRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\r\n const result = await this._requestsHandler.getDisplayLabelDefinition(rpcOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(result);\r\n }\r\n\r\n /** Retrieves display label definition of specific items. */\r\n public async getDisplayLabelDefinitionsIterator(\r\n requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: AsyncIterableIterator<LabelDefinition> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (page) => {\r\n const partialKeys = !page.start ? rpcOptions.keys : rpcOptions.keys.slice(page.start);\r\n const result = await this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });\r\n result.items = this._localizationHelper.getLocalizedLabelDefinitions(result.items);\r\n return result;\r\n },\r\n });\r\n\r\n return generator.createAsyncIteratorResponse();\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific items.\r\n * @deprecated in 4.5. Use [[getDisplayLabelDefinitionsIterator]] instead.\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions,\r\n ): Promise<LabelDefinition[]> {\r\n const { items } = await this.getDisplayLabelDefinitionsIterator(requestOptions);\r\n return collect(items);\r\n }\r\n}\r\n\r\nconst getDescriptorOverrides = (descriptorOrOverrides: Descriptor | DescriptorOverrides): DescriptorOverrides => {\r\n if (descriptorOrOverrides instanceof Descriptor) {\r\n return descriptorOrOverrides.createDescriptorOverrides();\r\n }\r\n return descriptorOrOverrides;\r\n};\r\n\r\nconst stripTransientElementKeys = (keys: KeySet) => {\r\n if (!keys.some((key) => Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME)) {\r\n return keys;\r\n }\r\n\r\n const copy = new KeySet();\r\n copy.add(keys, (key) => {\r\n // the callback is not going to be called with EntityProps as KeySet converts them\r\n // to InstanceKeys, but we want to keep the EntityProps case for correctness\r\n // istanbul ignore next\r\n const isTransient =\r\n (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) ||\r\n (Key.isEntityProps(key) && key.classFullName === TRANSIENT_ELEMENT_CLASSNAME);\r\n return !isTransient;\r\n });\r\n return copy;\r\n};\r\n\r\nasync function collect<T>(iter: AsyncIterable<T>): Promise<T[]> {\r\n const result = new Array<T>();\r\n for await (const value of iter) {\r\n result.push(value);\r\n }\r\n return result;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAe,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,SAAS,EAAoB,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG3E,OAAO,EACL,sBAAsB,EAEtB,OAAO,EAEP,YAAY,EACZ,gBAAgB,EAEhB,6BAA6B,EAI7B,0BAA0B,EAC1B,UAAU,EAIV,i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Y,UAAU,EAAE,CAAC;QAChD,OAAO,qBAAqB,CAAC,yBAAyB,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC;AAEF,MAAM,yBAAyB,GAAG,CAAC,IAAY,EAAE,EAAE;IACjD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B,CAAC,EAAE,CAAC;QACjG,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;QACrB,kFAAkF;QAClF,4EAA4E;QAC5E,uBAAuB;QACvB,MAAM,WAAW,GACf,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B,CAAC;YACzE,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,aAAa,KAAK,2BAA2B,CAAC,CAAC;QAChF,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,KAAK,UAAU,OAAO,CAAI,IAAsB;IAC9C,MAAM,MAAM,GAAG,IAAI,KAAK,EAAK,CAAC;IAC9B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,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 Core\r\n */\r\n\r\nimport { BeEvent, CompressedId64Set, IDisposable, OrderedId64Iterable } from \"@itwin/core-bentley\";\r\nimport { IModelApp, IModelConnection, IpcApp } from \"@itwin/core-frontend\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport { SchemaContext } from \"@itwin/ecschema-metadata\";\r\nimport {\r\n buildElementProperties,\r\n ClientDiagnosticsAttribute,\r\n Content,\r\n ContentDescriptorRequestOptions,\r\n ContentFlags,\r\n ContentFormatter,\r\n ContentInstanceKeysRequestOptions,\r\n ContentPropertyValueFormatter,\r\n ContentRequestOptions,\r\n ContentSourcesRequestOptions,\r\n ContentUpdateInfo,\r\n DefaultContentDisplayTypes,\r\n Descriptor,\r\n DescriptorOverrides,\r\n DisplayLabelRequestOptions,\r\n DisplayLabelsRequestOptions,\r\n DisplayValueGroup,\r\n DistinctValuesRequestOptions,\r\n ElementProperties,\r\n FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions,\r\n FormatsMap,\r\n HierarchyLevelDescriptorRequestOptions,\r\n HierarchyRequestOptions,\r\n HierarchyUpdateInfo,\r\n InstanceKey,\r\n Item,\r\n ItemJSON,\r\n Key,\r\n KeySet,\r\n KoqPropertyValueFormatter,\r\n LabelDefinition,\r\n Node,\r\n NodeKey,\r\n NodePathElement,\r\n Paged,\r\n PagedResponse,\r\n PageOptions,\r\n PresentationIpcEvents,\r\n RpcRequestsHandler,\r\n Ruleset,\r\n RulesetVariable,\r\n SelectClassInfo,\r\n SingleElementPropertiesRequestOptions,\r\n UpdateInfo,\r\n VariableValueTypes,\r\n} from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\nimport { FrontendLocalizationHelper } from \"./LocalizationHelper\";\r\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\r\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\r\nimport { StreamedResponseGenerator } from \"./StreamedResponseGenerator\";\r\nimport { TRANSIENT_ELEMENT_CLASSNAME } from \"@itwin/unified-selection\";\r\n\r\n/**\r\n * Data structure that describes IModel hierarchy change event arguments.\r\n * @public\r\n */\r\nexport interface IModelHierarchyChangeEventArgs {\r\n /** Id of ruleset that was used to create hierarchy. */\r\n rulesetId: string;\r\n /** Hierarchy changes info. */\r\n updateInfo: HierarchyUpdateInfo;\r\n /** Key of iModel that was used to create hierarchy. It matches [[IModelConnection.key]] property. */\r\n imodelKey: string;\r\n}\r\n\r\n/**\r\n * Data structure that describes iModel content change event arguments.\r\n * @public\r\n */\r\nexport interface IModelContentChangeEventArgs {\r\n /** Id of ruleset that was used to create content. */\r\n rulesetId: string;\r\n /** Content changes info. */\r\n updateInfo: ContentUpdateInfo;\r\n /** Key of iModel that was used to create content. It matches [[IModelConnection.key]] property. */\r\n imodelKey: string;\r\n}\r\n\r\n/**\r\n * Options for requests that can return multiple pages of items concurrently.\r\n * @public\r\n */\r\nexport type MultipleValuesRequestOptions = Paged<{\r\n /**\r\n * Max number of requests that should be made to the backend to fulfill the whole request.\r\n * `undefined` means no limit, so in that case all requests are sent at once.\r\n */\r\n maxParallelRequests?: number;\r\n\r\n /**\r\n * Size of a single batch when fetching data through multiple requests. If not set,\r\n * the fall back is requested page size. If the page size is not set, the backend\r\n * decides how many items to return.\r\n */\r\n batchSize?: number;\r\n}>;\r\n\r\n/**\r\n * Options for requests that retrieve nodes.\r\n * @public\r\n */\r\nexport type GetNodesRequestOptions = HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute;\r\n\r\n/**\r\n * Options for requests that retrieve content.\r\n * @public\r\n */\r\nexport type GetContentRequestOptions = ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> &\r\n ClientDiagnosticsAttribute;\r\n\r\n/**\r\n * Options for requests that retrieve distinct values.\r\n * @public\r\n */\r\nexport type GetDistinctValuesRequestOptions = DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> &\r\n ClientDiagnosticsAttribute;\r\n\r\n/**\r\n * Properties used to configure [[PresentationManager]]\r\n * @public\r\n */\r\nexport interface PresentationManagerProps {\r\n /**\r\n * Sets the active locale to use when localizing presentation-related\r\n * strings. It can later be changed through [[PresentationManager]].\r\n */\r\n activeLocale?: string;\r\n\r\n /**\r\n * Sets the active unit system to use for formatting property values with\r\n * units. The value can later be changed through [[PresentationManager.activeUnitSystem]] setter or\r\n * overriden for each request through request parameters. If not set, `IModelApp.quantityFormatter.activeUnitSystem`\r\n * is used by default.\r\n *\r\n * @deprecated in 4.0. Use [IModelApp.quantityFormatter]($core-frontend) to set the active unit system.\r\n */\r\n activeUnitSystem?: UnitSystemKey;\r\n\r\n /**\r\n * ID used to identify client that requests data. Generally, clients should\r\n * store this ID in their local storage so the ID can be reused across\r\n * sessions - this allows reusing some caches.\r\n *\r\n * Defaults to a unique GUID as a client id.\r\n */\r\n clientId?: string;\r\n\r\n /**\r\n * Timeout (in milliseconds) for how long we're going to wait for RPC request to be fulfilled before throwing\r\n * a timeout error.\r\n *\r\n * Defaults to 10 minutes.\r\n */\r\n requestTimeout?: number;\r\n\r\n /**\r\n * Callback that provides [SchemaContext]($ecschema-metadata) for supplied [IModelConnection]($core-frontend).\r\n * [SchemaContext]($ecschema-metadata) is used for getting metadata required for values formatting.\r\n */\r\n schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\r\n\r\n /**\r\n * A map of default unit formats to use for formatting properties that don't have a presentation format\r\n * in requested unit system.\r\n *\r\n * @note Only has effect when frontend value formatting is enabled by supplying the `schemaContextProvider` prop.\r\n */\r\n defaultFormats?: FormatsMap;\r\n\r\n /** @internal */\r\n rpcRequestsHandler?: RpcRequestsHandler;\r\n\r\n /** @internal */\r\n ipcRequestsHandler?: IpcRequestsHandler;\r\n}\r\n\r\n/**\r\n * Frontend Presentation manager which basically just forwards all calls to\r\n * the backend implementation.\r\n *\r\n * @public\r\n */\r\nexport class PresentationManager implements IDisposable {\r\n private _requestsHandler: RpcRequestsHandler;\r\n private _rulesets: RulesetManager;\r\n private _localizationHelper: FrontendLocalizationHelper;\r\n private _explicitActiveUnitSystem: UnitSystemKey | undefined;\r\n private _rulesetVars: Map<string, RulesetVariablesManager>;\r\n private _clearEventListener?: () => void;\r\n private _schemaContextProvider?: (imodel: IModelConnection) => SchemaContext;\r\n private _defaultFormats?: FormatsMap;\r\n private _ipcRequestsHandler?: IpcRequestsHandler;\r\n\r\n /**\r\n * An event raised when hierarchies created using specific ruleset change\r\n */\r\n public onIModelHierarchyChanged = new BeEvent<(args: IModelHierarchyChangeEventArgs) => void>();\r\n\r\n /**\r\n * An event raised when content created using specific ruleset changes\r\n */\r\n public onIModelContentChanged = new BeEvent<(args: IModelContentChangeEventArgs) => void>();\r\n\r\n /**\r\n * Get / set active unit system used to format property values with units.\r\n *\r\n * @deprecated in 4.0. `IModelApp.quantityFormatter` should be used to get/set the active unit system. At the moment\r\n * [[PresentationManager]] allows overriding it, but returns `IModelApp.quantityFormatter.activeUnitSystem` if override\r\n * is not set.\r\n */\r\n public get activeUnitSystem(): UnitSystemKey {\r\n return this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem;\r\n }\r\n public set activeUnitSystem(value: UnitSystemKey | undefined) {\r\n this._explicitActiveUnitSystem = value;\r\n }\r\n\r\n private constructor(props?: PresentationManagerProps) {\r\n if (props) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this._explicitActiveUnitSystem = props.activeUnitSystem;\r\n }\r\n\r\n this._requestsHandler =\r\n props?.rpcRequestsHandler ?? new RpcRequestsHandler(props ? { clientId: props.clientId, timeout: props.requestTimeout } : undefined);\r\n this._rulesetVars = new Map<string, RulesetVariablesManager>();\r\n this._rulesets = RulesetManagerImpl.create();\r\n this._localizationHelper = new FrontendLocalizationHelper(props?.activeLocale);\r\n this._schemaContextProvider = props?.schemaContextProvider;\r\n this._defaultFormats = props?.defaultFormats;\r\n\r\n if (IpcApp.isValid) {\r\n // Ipc only works in ipc apps, so the `onUpdate` callback will only be called there.\r\n this._clearEventListener = IpcApp.addListener(PresentationIpcEvents.Update, this.onUpdate);\r\n this._ipcRequestsHandler = props?.ipcRequestsHandler ?? new IpcRequestsHandler(this._requestsHandler.clientId);\r\n }\r\n }\r\n\r\n /** Get / set active locale used for localizing presentation data */\r\n public get activeLocale(): string | undefined {\r\n return this._localizationHelper.locale;\r\n }\r\n public set activeLocale(locale: string | undefined) {\r\n this._localizationHelper.locale = locale;\r\n }\r\n\r\n public dispose() {\r\n if (this._clearEventListener) {\r\n this._clearEventListener();\r\n this._clearEventListener = undefined;\r\n }\r\n }\r\n\r\n private onUpdate = (_evt: Event, report: UpdateInfo) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.handleUpdateAsync(report);\r\n };\r\n\r\n /** @note This is only called in native apps after changes in iModels */\r\n private async handleUpdateAsync(report: UpdateInfo) {\r\n for (const imodelKey in report) {\r\n // istanbul ignore if\r\n if (!report.hasOwnProperty(imodelKey)) {\r\n continue;\r\n }\r\n\r\n const imodelReport = report[imodelKey];\r\n for (const rulesetId in imodelReport) {\r\n // istanbul ignore if\r\n if (!imodelReport.hasOwnProperty(rulesetId)) {\r\n continue;\r\n }\r\n\r\n const updateInfo = imodelReport[rulesetId];\r\n if (updateInfo.content) {\r\n this.onIModelContentChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.content, imodelKey });\r\n }\r\n if (updateInfo.hierarchy) {\r\n this.onIModelHierarchyChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.hierarchy, imodelKey });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Function that is called when a new IModelConnection is used to retrieve data.\r\n * @internal\r\n */\r\n public startIModelInitialization(_: IModelConnection) {}\r\n\r\n /**\r\n * Function that should be called to finish initialization that was started at [[PresentationManager.startIModelInitialization]].\r\n * Can be removed when [[FavoritePropertiesManager.has]] and [[FavoritePropertiesManager.sortFields]] are removed.\r\n * @internal\r\n */\r\n public async ensureIModelInitialized(_: IModelConnection) {}\r\n\r\n /**\r\n * Create a new PresentationManager instance\r\n * @param props Optional properties used to configure the manager\r\n */\r\n public static create(props?: PresentationManagerProps) {\r\n return new PresentationManager(props);\r\n }\r\n\r\n /** @internal */\r\n public get rpcRequestsHandler() {\r\n return this._requestsHandler;\r\n }\r\n\r\n /** @internal */\r\n public get ipcRequestsHandler() {\r\n return this._ipcRequestsHandler;\r\n }\r\n\r\n /**\r\n * Get rulesets manager\r\n */\r\n public rulesets() {\r\n return this._rulesets;\r\n }\r\n\r\n /**\r\n * Get ruleset variables manager for specific ruleset\r\n * @param rulesetId Id of the ruleset to get the vars manager for\r\n */\r\n public vars(rulesetId: string) {\r\n if (!this._rulesetVars.has(rulesetId)) {\r\n const varsManager = new RulesetVariablesManagerImpl(rulesetId, this._ipcRequestsHandler);\r\n this._rulesetVars.set(rulesetId, varsManager);\r\n }\r\n return this._rulesetVars.get(rulesetId)!;\r\n }\r\n\r\n private toRpcTokenOptions<TOptions extends { imodel: IModelConnection; locale?: string; unitSystem?: UnitSystemKey; rulesetVariables?: RulesetVariable[] }>(\r\n requestOptions: TOptions,\r\n ) {\r\n // 1. put default `locale` and `unitSystem`\r\n // 2. put all `requestOptions` members (if `locale` or `unitSystem` are set, they'll override the defaults put at #1)\r\n // 3. put `imodel` of type `IModelRpcProps` which overwrites the `imodel` from `requestOptions` put at #2\r\n const defaultOptions: Pick<TOptions, \"locale\" | \"unitSystem\"> = {};\r\n if (this.activeLocale) {\r\n defaultOptions.locale = this.activeLocale;\r\n }\r\n defaultOptions.unitSystem = this.activeUnitSystem; // eslint-disable-line @typescript-eslint/no-deprecated\r\n\r\n const { imodel, rulesetVariables, ...rpcRequestOptions } = requestOptions;\r\n return {\r\n ...defaultOptions,\r\n ...rpcRequestOptions,\r\n ...(rulesetVariables ? { rulesetVariables: rulesetVariables.map(RulesetVariable.toJSON) } : {}),\r\n imodel: imodel.getRpcProps(),\r\n };\r\n }\r\n\r\n private async addRulesetAndVariablesToOptions<TOptions extends { rulesetOrId: Ruleset | string; rulesetVariables?: RulesetVariable[] }>(options: TOptions) {\r\n const { rulesetOrId, rulesetVariables } = options;\r\n let foundRulesetOrId: Ruleset | string;\r\n if (typeof rulesetOrId === \"object\") {\r\n foundRulesetOrId = rulesetOrId;\r\n } else {\r\n const foundRuleset = await this._rulesets.get(rulesetOrId);\r\n foundRulesetOrId = foundRuleset ? foundRuleset.toJSON() : rulesetOrId;\r\n }\r\n const rulesetId = typeof foundRulesetOrId === \"object\" ? foundRulesetOrId.id : foundRulesetOrId;\r\n\r\n // All Id64Array variable values must be sorted for serialization to JSON to work. RulesetVariablesManager\r\n // sorts them before storing, so that part is taken care of, but we need to ensure that variables coming from\r\n // request options are also sorted.\r\n const variables = (rulesetVariables ?? []).map((variable) => {\r\n if (variable.type === VariableValueTypes.Id64Array) {\r\n return { ...variable, value: OrderedId64Iterable.sortArray(variable.value) };\r\n }\r\n return variable;\r\n });\r\n if (!this._ipcRequestsHandler) {\r\n // only need to add variables from variables manager if there's no IPC\r\n // handler - if there is one, the variables are already known by the backend\r\n variables.push(...this.vars(rulesetId).getAllVariables());\r\n }\r\n\r\n return { ...options, rulesetOrId: foundRulesetOrId, rulesetVariables: variables };\r\n }\r\n\r\n /** Returns an iterator that polls nodes asynchronously. */\r\n public async getNodesIterator(\r\n requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: AsyncIterableIterator<Node> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (paging) => {\r\n const result = await this._requestsHandler.getPagedNodes({ ...rpcOptions, paging });\r\n return {\r\n total: result.total,\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n items: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),\r\n };\r\n },\r\n });\r\n\r\n return generator.createAsyncIteratorResponse();\r\n }\r\n\r\n /**\r\n * Retrieves nodes\r\n * @deprecated in 4.5. Use [[getNodesIterator]] instead.\r\n */\r\n public async getNodes(requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions): Promise<Node[]> {\r\n const result = await this.getNodesIterator(requestOptions);\r\n return collect(result.items);\r\n }\r\n\r\n /** Retrieves nodes count. */\r\n public async getNodesCount(requestOptions: GetNodesRequestOptions): Promise<number> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n return this._requestsHandler.getNodesCount(rpcOptions);\r\n }\r\n\r\n /**\r\n * Retrieves total nodes count and a single page of nodes.\r\n * @deprecated in 4.5. Use [[getNodesIterator]] instead.\r\n */\r\n public async getNodesAndCount(requestOptions: GetNodesRequestOptions & MultipleValuesRequestOptions): Promise<{ count: number; nodes: Node[] }> {\r\n const result = await this.getNodesIterator(requestOptions);\r\n return {\r\n count: result.total,\r\n nodes: await collect(result.items),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor.\r\n * @public\r\n */\r\n public async getNodesDescriptor(\r\n requestOptions: HierarchyLevelDescriptorRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n try {\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await this._requestsHandler.getNodesDescriptor(rpcOptions);\r\n const descriptor = Descriptor.fromJSON(result);\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n } finally {\r\n await this.ensureIModelInitialized(requestOptions.imodel);\r\n }\r\n }\r\n\r\n /** Retrieves paths from root nodes to children nodes according to specified keys. Intersecting paths will be merged. */\r\n public async getNodePaths(\r\n requestOptions: FilterByInstancePathsHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await this._requestsHandler.getNodePaths(rpcOptions);\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return result.map(NodePathElement.fromJSON).map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /** Retrieves paths from root nodes to nodes containing filter text in their label. */\r\n public async getFilteredNodePaths(\r\n requestOptions: FilterByTextHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<NodePathElement[]> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const result = await this._requestsHandler.getFilteredNodePaths(this.toRpcTokenOptions(options));\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return result.map(NodePathElement.fromJSON).map((npe) => this._localizationHelper.getLocalizedNodePathElement(npe));\r\n }\r\n\r\n /**\r\n * Get information about the sources of content when building it for specific ECClasses. Sources involve classes of the primary select instance,\r\n * its related instances for loading related and navigation properties.\r\n * @public\r\n */\r\n public async getContentSources(requestOptions: ContentSourcesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute): Promise<SelectClassInfo[]> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions(requestOptions);\r\n const result = await this._requestsHandler.getContentSources(rpcOptions);\r\n return SelectClassInfo.listFromCompressedJSON(result.sources, result.classesMap);\r\n }\r\n\r\n /** Retrieves the content descriptor which describes the content and can be used to customize it. */\r\n public async getContentDescriptor(\r\n requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute,\r\n ): Promise<Descriptor | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n try {\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n });\r\n const result = await this._requestsHandler.getContentDescriptor(rpcOptions);\r\n const descriptor = Descriptor.fromJSON(result);\r\n return descriptor ? this._localizationHelper.getLocalizedContentDescriptor(descriptor) : undefined;\r\n } finally {\r\n await this.ensureIModelInitialized(requestOptions.imodel);\r\n }\r\n }\r\n\r\n /** Retrieves overall content set size. */\r\n public async getContentSetSize(requestOptions: GetContentRequestOptions): Promise<number> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\r\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\r\n });\r\n return this._requestsHandler.getContentSetSize(rpcOptions);\r\n }\r\n\r\n private async getContentIteratorInternal(\r\n requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ descriptor: Descriptor; total: number; items: AsyncIterableIterator<Item> } | undefined> {\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const firstPageSize = options.batchSize ?? requestOptions.paging?.size;\r\n const rpcOptions = this.toRpcTokenOptions({\r\n ...options,\r\n descriptor: getDescriptorOverrides(requestOptions.descriptor),\r\n keys: stripTransientElementKeys(requestOptions.keys).toJSON(),\r\n ...(firstPageSize ? { paging: { ...requestOptions.paging, size: firstPageSize } } : undefined),\r\n ...(!requestOptions.omitFormattedValues && this._schemaContextProvider !== undefined ? { omitFormattedValues: true } : undefined),\r\n });\r\n\r\n let contentFormatter: ContentFormatter | undefined;\r\n if (!requestOptions.omitFormattedValues && this._schemaContextProvider) {\r\n const koqPropertyFormatter = new KoqPropertyValueFormatter(this._schemaContextProvider(requestOptions.imodel), this._defaultFormats);\r\n contentFormatter = new ContentFormatter(\r\n new ContentPropertyValueFormatter(koqPropertyFormatter),\r\n requestOptions.unitSystem ?? this._explicitActiveUnitSystem ?? IModelApp.quantityFormatter.activeUnitSystem,\r\n );\r\n }\r\n\r\n let descriptor = requestOptions.descriptor instanceof Descriptor ? requestOptions.descriptor : undefined;\r\n let firstPage: PagedResponse<ItemJSON> | undefined;\r\n if (!descriptor) {\r\n const firstPageResponse = await this._requestsHandler.getPagedContent(rpcOptions);\r\n if (!firstPageResponse?.descriptor || !firstPageResponse.contentSet) {\r\n return undefined;\r\n }\r\n descriptor = Descriptor.fromJSON(firstPageResponse?.descriptor);\r\n firstPage = firstPageResponse?.contentSet;\r\n }\r\n\r\n // istanbul ignore if\r\n if (!descriptor) {\r\n return undefined;\r\n }\r\n\r\n descriptor = this._localizationHelper.getLocalizedContentDescriptor(descriptor);\r\n\r\n const getPage = async (paging: Required<PageOptions>, requestIndex: number) => {\r\n let contentSet = requestIndex === 0 ? firstPage : undefined;\r\n contentSet ??= await this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging });\r\n\r\n let items = contentSet.items.map((x) => Item.fromJSON(x)).filter((x): x is Item => x !== undefined);\r\n if (contentFormatter) {\r\n items = await contentFormatter.formatContentItems(items, descriptor);\r\n }\r\n\r\n items = this._localizationHelper.getLocalizedContentItems(items);\r\n return {\r\n total: contentSet.total,\r\n items,\r\n };\r\n };\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: getPage,\r\n });\r\n\r\n return {\r\n ...(await generator.createAsyncIteratorResponse()),\r\n descriptor,\r\n };\r\n }\r\n\r\n /** Retrieves a content descriptor, item count and async generator for the items themselves. */\r\n public async getContentIterator(\r\n requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ descriptor: Descriptor; total: number; items: AsyncIterableIterator<Item> } | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const response = await this.getContentIteratorInternal(requestOptions);\r\n if (!response) {\r\n return undefined;\r\n }\r\n\r\n await this.ensureIModelInitialized(requestOptions.imodel);\r\n return response;\r\n }\r\n\r\n /**\r\n * Retrieves content which consists of a content descriptor and a page of records.\r\n * @deprecated in 4.5. Use [[getContentIterator]] instead.\r\n */\r\n public async getContent(requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions): Promise<Content | undefined> {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return (await this.getContentAndSize(requestOptions))?.content;\r\n }\r\n\r\n /**\r\n * Retrieves content set size and content which consists of a content descriptor and a page of records.\r\n * @deprecated in 4.5. Use [[getContentIterator]] instead.\r\n */\r\n public async getContentAndSize(\r\n requestOptions: GetContentRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ content: Content; size: number } | undefined> {\r\n const response = await this.getContentIterator(requestOptions);\r\n if (!response) {\r\n return undefined;\r\n }\r\n\r\n const { descriptor, total } = response;\r\n const items = await collect(response.items);\r\n return {\r\n content: new Content(descriptor, items),\r\n size: total,\r\n };\r\n }\r\n\r\n /** Returns an iterator that asynchronously polls distinct values of specific field from the content. */\r\n public async getDistinctValuesIterator(\r\n requestOptions: GetDistinctValuesRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: AsyncIterableIterator<DisplayValueGroup> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = {\r\n ...this.toRpcTokenOptions(options),\r\n descriptor: getDescriptorOverrides(options.descriptor),\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n };\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (paging) => {\r\n const response = await this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging });\r\n return {\r\n total: response.total,\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n items: response.items.map((x) => this._localizationHelper.getLocalizedDisplayValueGroup(DisplayValueGroup.fromJSON(x))),\r\n };\r\n },\r\n });\r\n\r\n return generator.createAsyncIteratorResponse();\r\n }\r\n\r\n /**\r\n * Retrieves distinct values of specific field from the content.\r\n * @deprecated in 4.5. Use [[getDistinctValuesIterator]] instead.\r\n */\r\n public async getPagedDistinctValues(\r\n requestOptions: GetDistinctValuesRequestOptions & MultipleValuesRequestOptions,\r\n ): Promise<PagedResponse<DisplayValueGroup>> {\r\n const result = await this.getDistinctValuesIterator(requestOptions);\r\n return {\r\n total: result.total,\r\n items: await collect(result.items),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves property data in a simplified format for a single element specified by ID.\r\n * @public\r\n */\r\n public async getElementProperties<TParsedContent = ElementProperties>(\r\n requestOptions: SingleElementPropertiesRequestOptions<IModelConnection, TParsedContent> & ClientDiagnosticsAttribute,\r\n ): Promise<TParsedContent | undefined> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n type TParser = Required<typeof requestOptions>[\"contentParser\"];\r\n const { elementId, contentParser, ...optionsNoElementId } = requestOptions;\r\n const parser: TParser = contentParser ?? (buildElementProperties as TParser);\r\n const iter = await this.getContentIterator({\r\n ...optionsNoElementId,\r\n descriptor: {\r\n displayType: DefaultContentDisplayTypes.PropertyPane,\r\n contentFlags: ContentFlags.ShowLabels,\r\n },\r\n rulesetOrId: \"ElementProperties\",\r\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\r\n });\r\n if (!iter || iter.total === 0) {\r\n return undefined;\r\n }\r\n return parser(iter.descriptor, (await iter.items.next()).value);\r\n }\r\n\r\n /**\r\n * Retrieves content item instance keys.\r\n * @public\r\n */\r\n public async getContentInstanceKeys(\r\n requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: () => AsyncGenerator<InstanceKey> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = {\r\n ...this.toRpcTokenOptions(options),\r\n keys: stripTransientElementKeys(options.keys).toJSON(),\r\n };\r\n\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (page) => {\r\n const keys = await this._requestsHandler.getContentInstanceKeys({ ...rpcOptions, paging: page });\r\n return {\r\n total: keys.total,\r\n items: keys.items.instanceKeys.reduce((instanceKeys, entry) => {\r\n for (const id of CompressedId64Set.iterable(entry[1])) {\r\n instanceKeys.push({ className: entry[0], id });\r\n }\r\n return instanceKeys;\r\n }, new Array<InstanceKey>()),\r\n };\r\n },\r\n });\r\n\r\n const { total, items } = await generator.createAsyncIteratorResponse();\r\n return {\r\n total,\r\n async *items() {\r\n yield* items;\r\n },\r\n };\r\n }\r\n\r\n /** Retrieves display label definition of specific item. */\r\n public async getDisplayLabelDefinition(\r\n requestOptions: DisplayLabelRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute,\r\n ): Promise<LabelDefinition> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\r\n const result = await this._requestsHandler.getDisplayLabelDefinition(rpcOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(result);\r\n }\r\n\r\n /** Retrieves display label definition of specific items. */\r\n public async getDisplayLabelDefinitionsIterator(\r\n requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions,\r\n ): Promise<{ total: number; items: AsyncIterableIterator<LabelDefinition> }> {\r\n this.startIModelInitialization(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\r\n const generator = new StreamedResponseGenerator({\r\n ...requestOptions,\r\n getBatch: async (page) => {\r\n const partialKeys = !page.start ? rpcOptions.keys : rpcOptions.keys.slice(page.start);\r\n const result = await this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });\r\n result.items = this._localizationHelper.getLocalizedLabelDefinitions(result.items);\r\n return result;\r\n },\r\n });\r\n\r\n return generator.createAsyncIteratorResponse();\r\n }\r\n\r\n /**\r\n * Retrieves display label definition of specific items.\r\n * @deprecated in 4.5. Use [[getDisplayLabelDefinitionsIterator]] instead.\r\n */\r\n public async getDisplayLabelDefinitions(\r\n requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute & MultipleValuesRequestOptions,\r\n ): Promise<LabelDefinition[]> {\r\n const { items } = await this.getDisplayLabelDefinitionsIterator(requestOptions);\r\n return collect(items);\r\n }\r\n}\r\n\r\nconst getDescriptorOverrides = (descriptorOrOverrides: Descriptor | DescriptorOverrides): DescriptorOverrides => {\r\n if (descriptorOrOverrides instanceof Descriptor) {\r\n return descriptorOrOverrides.createDescriptorOverrides();\r\n }\r\n return descriptorOrOverrides;\r\n};\r\n\r\nconst stripTransientElementKeys = (keys: KeySet) => {\r\n if (!keys.some((key) => Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME)) {\r\n return keys;\r\n }\r\n\r\n const copy = new KeySet();\r\n copy.add(keys, (key) => {\r\n // the callback is not going to be called with EntityProps as KeySet converts them\r\n // to InstanceKeys, but we want to keep the EntityProps case for correctness\r\n // istanbul ignore next\r\n const isTransient =\r\n (Key.isInstanceKey(key) && key.className === TRANSIENT_ELEMENT_CLASSNAME) ||\r\n (Key.isEntityProps(key) && key.classFullName === TRANSIENT_ELEMENT_CLASSNAME);\r\n return !isTransient;\r\n });\r\n return copy;\r\n};\r\n\r\nasync function collect<T>(iter: AsyncIterable<T>): Promise<T[]> {\r\n const result = new Array<T>();\r\n for await (const value of iter) {\r\n result.push(value);\r\n }\r\n return result;\r\n}\r\n"]}
|
|
@@ -9,8 +9,8 @@ import { from, shareReplay } from "rxjs";
|
|
|
9
9
|
import { eachValueFrom } from "rxjs-for-await";
|
|
10
10
|
import { ContentFlags, DEFAULT_KEYS_BATCH_SIZE, DefaultContentDisplayTypes, Key, KeySet } from "@itwin/presentation-common";
|
|
11
11
|
import { Presentation } from "../Presentation";
|
|
12
|
-
import { TRANSIENT_ELEMENT_CLASSNAME } from "./SelectionManager";
|
|
13
12
|
import hiliteRuleset from "./HiliteRules.json";
|
|
13
|
+
import { TRANSIENT_ELEMENT_CLASSNAME } from "@itwin/unified-selection";
|
|
14
14
|
const HILITE_RULESET = hiliteRuleset;
|
|
15
15
|
/**
|
|
16
16
|
* Presentation-based provider which uses presentation ruleset to determine
|
|
@@ -1 +1 @@
|
|
|
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,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,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;IACtC,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,YAAY,CAAC,SAA2B;QACnD,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAc,CAAC;QACzC,MA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ACzB,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":["/*---------------------------------------------------------------------------------------------\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 { TRANSIENT_ELEMENT_CLASSNAME } from \"./SelectionManager\";\r\nimport hiliteRuleset from \"./HiliteRules.json\";\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,oBAAo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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"]}
|
|
@@ -147,8 +147,6 @@ export declare class SelectionManager implements ISelectionProvider {
|
|
|
147
147
|
private streamSelectionEvents;
|
|
148
148
|
}
|
|
149
149
|
/** @internal */
|
|
150
|
-
export declare const TRANSIENT_ELEMENT_CLASSNAME = "/TRANSIENT";
|
|
151
|
-
/** @internal */
|
|
152
150
|
export declare class ToolSelectionSyncHandler implements IDisposable {
|
|
153
151
|
private _selectionSourceName;
|
|
154
152
|
private _logicalSelection;
|