@itwin/presentation-frontend 3.6.0-dev.8 → 4.0.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  4. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +0 -1
  5. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  6. package/lib/cjs/presentation-frontend/PresentationManager.d.ts +11 -5
  7. package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
  8. package/lib/cjs/presentation-frontend/PresentationManager.js +30 -13
  9. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  10. package/lib/cjs/presentation-frontend/RulesetManager.d.ts +5 -2
  11. package/lib/cjs/presentation-frontend/RulesetManager.d.ts.map +1 -1
  12. package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
  13. package/lib/cjs/presentation-frontend/StateTracker.d.ts +18 -3
  14. package/lib/cjs/presentation-frontend/StateTracker.d.ts.map +1 -1
  15. package/lib/cjs/presentation-frontend/StateTracker.js +104 -49
  16. package/lib/cjs/presentation-frontend/StateTracker.js.map +1 -1
  17. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +1 -1
  18. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +1 -1
  19. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  20. package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  21. package/lib/esm/presentation-frontend/IpcRequestsHandler.js +1 -2
  22. package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  23. package/lib/esm/presentation-frontend/PresentationManager.d.ts +11 -5
  24. package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
  25. package/lib/esm/presentation-frontend/PresentationManager.js +31 -14
  26. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  27. package/lib/esm/presentation-frontend/RulesetManager.d.ts +5 -2
  28. package/lib/esm/presentation-frontend/RulesetManager.d.ts.map +1 -1
  29. package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
  30. package/lib/esm/presentation-frontend/StateTracker.d.ts +18 -3
  31. package/lib/esm/presentation-frontend/StateTracker.d.ts.map +1 -1
  32. package/lib/esm/presentation-frontend/StateTracker.js +103 -48
  33. package/lib/esm/presentation-frontend/StateTracker.js.map +1 -1
  34. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +1 -1
  35. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +1 -1
  36. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  37. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAe,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAoB,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EACuB,OAAO,EACc,UAAU,EAC3D,iBAAiB,EACkE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EACpI,eAAe,EAAqC,qBAAqB,EAAE,kBAAkB,EAAW,eAAe,EACpI,eAAe,EAAyC,UAAU,EAAkB,kBAAkB,GACvG,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAkB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAA2B,2BAA2B,EAAE,MAAM,2BAA2B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,CAAC;QACjF,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,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 { IModelConnection, IpcApp } from \"@itwin/core-frontend\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\r\n ClientDiagnosticsAttribute, Content, ContentDescriptorRequestOptions, ContentInstanceKeysRequestOptions, ContentRequestOptions,\r\n ContentSourcesRequestOptions, ContentUpdateInfo, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions,\r\n DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions, HierarchyRequestOptions, HierarchyUpdateInfo, InstanceKey, Item, Key, KeySet, LabelDefinition, Node, NodeKey,\r\n NodeKeyJSON, NodePathElement, Paged, PagedResponse, PageOptions, PresentationIpcEvents, RpcRequestsHandler, Ruleset, RulesetVariable,\r\n SelectClassInfo, SingleElementPropertiesRequestOptions, UpdateInfo, UpdateInfoJSON, 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 { StateTracker } from \"./StateTracker\";\r\n\r\n/**\r\n * Data structure that describes IModel hierarchy change event arguments.\r\n * @alpha\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 * @alpha\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 * 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. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager]] or overriden for each request.\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 /** @internal */\r\n rpcRequestsHandler?: RpcRequestsHandler;\r\n\r\n /** @internal */\r\n ipcRequestsHandler?: IpcRequestsHandler;\r\n\r\n /** @internal */\r\n stateTracker?: StateTracker;\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 _rulesetVars: Map<string, RulesetVariablesManager>;\r\n private _clearEventListener?: () => void;\r\n private _connections: Map<IModelConnection, Promise<void>>;\r\n private _ipcRequestsHandler?: IpcRequestsHandler;\r\n private _stateTracker?: StateTracker;\r\n\r\n /**\r\n * An event raised when hierarchies created using specific ruleset change\r\n * @alpha\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 * @alpha\r\n */\r\n public onIModelContentChanged = new BeEvent<(args: IModelContentChangeEventArgs) => void>();\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public activeUnitSystem: UnitSystemKey | undefined;\r\n\r\n private constructor(props?: PresentationManagerProps) {\r\n if (props) {\r\n this.activeUnitSystem = props.activeUnitSystem;\r\n }\r\n\r\n this._requestsHandler = props?.rpcRequestsHandler ?? new RpcRequestsHandler(props ? { clientId: props.clientId } : 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._connections = new Map<IModelConnection, Promise<void>>();\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 this._stateTracker = props?.stateTracker ?? new StateTracker(this._ipcRequestsHandler);\r\n }\r\n }\r\n\r\n /** Get / set active locale used for localizing presentation data */\r\n public get activeLocale(): string | undefined { return this._localizationHelper.locale; }\r\n public set activeLocale(locale: string | undefined) { this._localizationHelper.locale = locale; }\r\n\r\n public dispose() {\r\n this._requestsHandler.dispose();\r\n if (this._clearEventListener) {\r\n this._clearEventListener();\r\n this._clearEventListener = undefined;\r\n }\r\n }\r\n\r\n private async onConnection(imodel: IModelConnection) {\r\n if (!this._connections.has(imodel))\r\n this._connections.set(imodel, this.initializeIModel(imodel));\r\n await this._connections.get(imodel);\r\n }\r\n\r\n private async initializeIModel(imodel: IModelConnection) {\r\n imodel.onClose.addOnce(() => {\r\n this._connections.delete(imodel);\r\n });\r\n await this.onNewiModelConnection(imodel);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onUpdate = (_evt: Event, report: UpdateInfoJSON) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.handleUpdateAsync(UpdateInfo.fromJSON(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 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 const updateInfo = imodelReport[rulesetId];\r\n if (updateInfo.content)\r\n this.onIModelContentChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.content, imodelKey });\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 /** Function that is called when a new IModelConnection is used to retrieve data.\r\n * @internal\r\n */\r\n public async onNewiModelConnection(_: 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() { return this._requestsHandler; }\r\n\r\n /** @internal */\r\n public get ipcRequestsHandler() { return this._ipcRequestsHandler; }\r\n\r\n /** @internal */\r\n public get stateTracker() { return this._stateTracker; }\r\n\r\n /**\r\n * Get rulesets manager\r\n */\r\n public rulesets() { return this._rulesets; }\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[] }>(requestOptions: TOptions) {\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 if (this.activeUnitSystem)\r\n defaultOptions.unitSystem = this.activeUnitSystem;\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 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 /** Retrieves nodes */\r\n public async getNodes(requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<Node[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options, parentKey: optionalNodeKeyToJson(options.parentKey) });\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));\r\n return this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON));\r\n }\r\n\r\n /** Retrieves nodes count. */\r\n public async getNodesCount(requestOptions: HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute): Promise<number> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options, parentKey: optionalNodeKeyToJson(options.parentKey) });\r\n return this._requestsHandler.getNodesCount(rpcOptions);\r\n }\r\n\r\n /** Retrieves total nodes count and a single page of nodes. */\r\n public async getNodesAndCount(requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<{ count: number, nodes: Node[] }> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options, parentKey: optionalNodeKeyToJson(options.parentKey) });\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));\r\n return {\r\n count: result.total,\r\n nodes: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),\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(requestOptions: FilterByInstancePathsHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute): Promise<NodePathElement[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options, instancePaths: options.instancePaths.map((p) => p.map(InstanceKey.toJSON)) });\r\n const result = await this._requestsHandler.getNodePaths(rpcOptions);\r\n return result.map(NodePathElement.fromJSON);\r\n }\r\n\r\n /** Retrieves paths from root nodes to nodes containing filter text in their label. */\r\n public async getFilteredNodePaths(requestOptions: FilterByTextHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute): Promise<NodePathElement[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const result = await this._requestsHandler.getFilteredNodePaths(this.toRpcTokenOptions(options));\r\n return result.map(NodePathElement.fromJSON);\r\n }\r\n\r\n /**\r\n * Get all content sources for a given list of classes.\r\n * @beta\r\n */\r\n public async getContentSources(requestOptions: ContentSourcesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute): Promise<SelectClassInfo[]> {\r\n await this.onConnection(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(requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<Descriptor | undefined> {\r\n await this.onConnection(requestOptions.imodel);\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 return Descriptor.fromJSON(result);\r\n }\r\n\r\n /** Retrieves overall content set size. */\r\n public async getContentSetSize(requestOptions: ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<number> {\r\n await this.onConnection(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 /** Retrieves content which consists of a content descriptor and a page of records. */\r\n public async getContent(requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<Content | undefined> {\r\n return (await this.getContentAndSize(requestOptions))?.content;\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 public async getContentAndSize(requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<{ content: Content, size: number } | undefined> {\r\n await this.onConnection(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 let descriptor = (requestOptions.descriptor instanceof Descriptor) ? requestOptions.descriptor : undefined;\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions, requestIndex) => {\r\n if (0 === requestIndex && !descriptor) {\r\n const content = await this._requestsHandler.getPagedContent({ ...rpcOptions, paging: partialPageOptions });\r\n if (content) {\r\n descriptor = Descriptor.fromJSON(content.descriptor);\r\n return content.contentSet;\r\n }\r\n return { total: 0, items: [] };\r\n }\r\n return this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging: partialPageOptions });\r\n });\r\n if (!descriptor)\r\n return undefined;\r\n const items = result.items.map((itemJson) => Item.fromJSON(itemJson)).filter<Item>((item): item is Item => (item !== undefined));\r\n return {\r\n size: result.total,\r\n content: this._localizationHelper.getLocalizedContent(new Content(descriptor, items)),\r\n };\r\n }\r\n\r\n /** Retrieves distinct values of specific field from the content. */\r\n public async getPagedDistinctValues(requestOptions: DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroup>> {\r\n await this.onConnection(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 const result = await buildPagedArrayResponse(requestOptions.paging, async (partialPageOptions) => this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging: partialPageOptions }));\r\n return {\r\n ...result,\r\n items: result.items.map(DisplayValueGroup.fromJSON),\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 * @beta\r\n */\r\n public async getElementProperties(requestOptions: SingleElementPropertiesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute): Promise<ElementProperties | undefined> {\r\n await this.onConnection(requestOptions.imodel);\r\n const results = await this._requestsHandler.getElementProperties(this.toRpcTokenOptions(requestOptions));\r\n // istanbul ignore if\r\n if (!results)\r\n return undefined;\r\n return this._localizationHelper.getLocalizedElementProperties(results);\r\n }\r\n\r\n /**\r\n * Retrieves content item instance keys.\r\n * @beta\r\n */\r\n public async getContentInstanceKeys(requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<{ total: number, items: () => AsyncGenerator<InstanceKey> }> {\r\n await this.onConnection(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 props = {\r\n page: requestOptions.paging,\r\n get: async (page: Required<PageOptions>) => {\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 return createPagedGeneratorResponse(props);\r\n }\r\n\r\n /** Retrieves display label definition of specific item. */\r\n public async getDisplayLabelDefinition(requestOptions: DisplayLabelRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition> {\r\n await this.onConnection(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions, key: InstanceKey.toJSON(requestOptions.key) });\r\n const result = await this._requestsHandler.getDisplayLabelDefinition(rpcOptions);\r\n return this._localizationHelper.getLocalizedLabelDefinition(LabelDefinition.fromJSON(result));\r\n }\r\n\r\n /** Retrieves display label definition of specific items. */\r\n public async getDisplayLabelDefinitions(requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions, keys: requestOptions.keys.map(InstanceKey.toJSON) });\r\n const result = await buildPagedArrayResponse(undefined, async (partialPageOptions) => {\r\n const partialKeys = (!partialPageOptions.start) ? rpcOptions.keys : rpcOptions.keys.slice(partialPageOptions.start);\r\n return this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });\r\n });\r\n return this._localizationHelper.getLocalizedLabelDefinitions(result.items.map(LabelDefinition.fromJSON));\r\n }\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 return descriptorOrOverrides;\r\n};\r\n\r\nconst optionalNodeKeyToJson = (key: NodeKey | undefined): NodeKeyJSON | undefined => key ? NodeKey.toJSON(key) : undefined;\r\n\r\ninterface PagedGeneratorCreateProps<TPagedResponseItem> {\r\n page: PageOptions | undefined;\r\n get: (pageStart: Required<PageOptions>, requestIndex: number) => Promise<{ total: number, items: TPagedResponseItem[] }>;\r\n}\r\nasync function createPagedGeneratorResponse<TPagedResponseItem>(props: PagedGeneratorCreateProps<TPagedResponseItem>) {\r\n let pageStart = props.page?.start ?? 0;\r\n let pageSize = props.page?.size ?? 0;\r\n let requestIndex = 0;\r\n\r\n const firstPage = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\r\n return {\r\n total: firstPage.total,\r\n async *items() {\r\n let partialResult = firstPage;\r\n while (true) {\r\n for (const item of partialResult.items) {\r\n yield item;\r\n }\r\n\r\n const receivedItemsCount = partialResult.items.length;\r\n if (partialResult.total !== 0 && receivedItemsCount === 0) {\r\n if (pageStart >= partialResult.total)\r\n throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${partialResult.total}`);\r\n throw new Error(\"Paged request returned non zero total count but no items\");\r\n }\r\n\r\n if (pageSize !== 0 && receivedItemsCount >= pageSize || receivedItemsCount >= (partialResult.total - pageStart))\r\n break;\r\n\r\n if (pageSize !== 0)\r\n pageSize -= receivedItemsCount;\r\n pageStart += receivedItemsCount;\r\n\r\n partialResult = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\r\n }\r\n },\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport const buildPagedArrayResponse = async <TItem>(requestedPage: PageOptions | undefined, getter: (page: Required<PageOptions>, requestIndex: number) => Promise<PagedResponse<TItem>>): Promise<PagedResponse<TItem>> => {\r\n try {\r\n const items = new Array<TItem>();\r\n const gen = await createPagedGeneratorResponse({ page: requestedPage, get: getter });\r\n for await (const item of gen.items()) {\r\n items.push(item);\r\n }\r\n return { total: gen.total, items };\r\n } catch {\r\n return { total: 0, items: [] };\r\n }\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 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 = 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"]}
1
+ {"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/PresentationManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAe,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAoB,MAAM,EAAE,MAAM,sBAAsB,CA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AC1B,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE;QACrB,kFAAkF;QAClF,4EAA4E;QAC5E,uBAAuB;QACvB,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,SAAS,KAAK,2BAA2B;eACtF,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,aAAa,KAAK,2BAA2B,CAAC;QACjF,OAAO,CAAC,WAAW,CAAC;IACtB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,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 { IModelConnection, IpcApp } from \"@itwin/core-frontend\";\r\nimport { UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\r\n ClientDiagnosticsAttribute, Content, ContentDescriptorRequestOptions, ContentInstanceKeysRequestOptions, ContentRequestOptions,\r\n ContentSourcesRequestOptions, ContentUpdateInfo, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions,\r\n DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions,\r\n FilterByTextHierarchyRequestOptions, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions, HierarchyUpdateInfo, InstanceKey, Item, Key,\r\n KeySet, LabelDefinition, Node, NodeKey, NodePathElement, Paged, PagedResponse, PageOptions, PresentationIpcEvents, RpcRequestsHandler, Ruleset,\r\n RulesetVariable, SelectClassInfo, SingleElementPropertiesRequestOptions, UpdateInfo, UpdateInfoJSON, 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 { StateTracker } from \"./StateTracker\";\r\n\r\n/**\r\n * Data structure that describes IModel hierarchy change event arguments.\r\n * @alpha\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 * @alpha\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 * 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. Default presentation units are used if this is not specified. The active unit\r\n * system can later be changed through [[PresentationManager]] or overriden for each request.\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 /** @internal */\r\n rpcRequestsHandler?: RpcRequestsHandler;\r\n\r\n /** @internal */\r\n ipcRequestsHandler?: IpcRequestsHandler;\r\n\r\n /** @internal */\r\n stateTracker?: StateTracker;\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 _rulesetVars: Map<string, RulesetVariablesManager>;\r\n private _clearEventListener?: () => void;\r\n private _connections: Map<IModelConnection, Promise<void>>;\r\n private _ipcRequestsHandler?: IpcRequestsHandler;\r\n private _stateTracker?: StateTracker;\r\n\r\n /**\r\n * An event raised when hierarchies created using specific ruleset change\r\n * @alpha\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 * @alpha\r\n */\r\n public onIModelContentChanged = new BeEvent<(args: IModelContentChangeEventArgs) => void>();\r\n\r\n /** Get / set active unit system used to format property values with units */\r\n public activeUnitSystem: UnitSystemKey | undefined;\r\n\r\n private constructor(props?: PresentationManagerProps) {\r\n if (props) {\r\n this.activeUnitSystem = props.activeUnitSystem;\r\n }\r\n\r\n this._requestsHandler = props?.rpcRequestsHandler ?? new RpcRequestsHandler(props ? { clientId: props.clientId } : 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._connections = new Map<IModelConnection, Promise<void>>();\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 this._stateTracker = props?.stateTracker ?? new StateTracker(this._ipcRequestsHandler);\r\n }\r\n }\r\n\r\n /** Get / set active locale used for localizing presentation data */\r\n public get activeLocale(): string | undefined { return this._localizationHelper.locale; }\r\n public set activeLocale(locale: string | undefined) { this._localizationHelper.locale = locale; }\r\n\r\n public dispose() {\r\n this._requestsHandler.dispose();\r\n if (this._clearEventListener) {\r\n this._clearEventListener();\r\n this._clearEventListener = undefined;\r\n }\r\n }\r\n\r\n private async onConnection(imodel: IModelConnection) {\r\n if (!this._connections.has(imodel))\r\n this._connections.set(imodel, this.initializeIModel(imodel));\r\n await this._connections.get(imodel);\r\n }\r\n\r\n private async initializeIModel(imodel: IModelConnection) {\r\n imodel.onClose.addOnce(() => {\r\n this._connections.delete(imodel);\r\n });\r\n await this.onNewiModelConnection(imodel);\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onUpdate = (_evt: Event, report: UpdateInfoJSON) => {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this.handleUpdateAsync(UpdateInfo.fromJSON(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 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 const updateInfo = imodelReport[rulesetId];\r\n if (updateInfo.content)\r\n this.onIModelContentChanged.raiseEvent({ rulesetId, updateInfo: updateInfo.content, imodelKey });\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 /** Function that is called when a new IModelConnection is used to retrieve data.\r\n * @internal\r\n */\r\n public async onNewiModelConnection(_: 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() { return this._requestsHandler; }\r\n\r\n /** @internal */\r\n public get ipcRequestsHandler() { return this._ipcRequestsHandler; }\r\n\r\n /** @internal */\r\n public get stateTracker() { return this._stateTracker; }\r\n\r\n /**\r\n * Get rulesets manager\r\n */\r\n public rulesets() { return this._rulesets; }\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[] }>(requestOptions: TOptions) {\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 if (this.activeUnitSystem)\r\n defaultOptions.unitSystem = this.activeUnitSystem;\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 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 /** Retrieves nodes */\r\n public async getNodes(requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<Node[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));\r\n // eslint-disable-next-line deprecation/deprecation\r\n return this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON));\r\n }\r\n\r\n /** Retrieves nodes count. */\r\n public async getNodesCount(requestOptions: HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute): Promise<number> {\r\n await this.onConnection(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 /** Retrieves total nodes count and a single page of nodes. */\r\n public async getNodesAndCount(requestOptions: Paged<HierarchyRequestOptions<IModelConnection, NodeKey, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<{ count: number, nodes: Node[] }> {\r\n await this.onConnection(requestOptions.imodel);\r\n const options = await this.addRulesetAndVariablesToOptions(requestOptions);\r\n const rpcOptions = this.toRpcTokenOptions({ ...options });\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions) => this._requestsHandler.getPagedNodes({ ...rpcOptions, paging: partialPageOptions }));\r\n return {\r\n count: result.total,\r\n // eslint-disable-next-line deprecation/deprecation\r\n nodes: this._localizationHelper.getLocalizedNodes(result.items.map(Node.fromJSON)),\r\n };\r\n }\r\n\r\n /**\r\n * Retrieves hierarchy level descriptor.\r\n * @beta\r\n */\r\n public async getNodesDescriptor(requestOptions: HierarchyLevelDescriptorRequestOptions<IModelConnection, NodeKey, RulesetVariable> & ClientDiagnosticsAttribute): Promise<Descriptor | undefined> {\r\n await this.onConnection(requestOptions.imodel);\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 return Descriptor.fromJSON(result);\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(requestOptions: FilterByInstancePathsHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute): Promise<NodePathElement[]> {\r\n await this.onConnection(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 deprecation/deprecation\r\n return result.map(NodePathElement.fromJSON);\r\n }\r\n\r\n /** Retrieves paths from root nodes to nodes containing filter text in their label. */\r\n public async getFilteredNodePaths(requestOptions: FilterByTextHierarchyRequestOptions<IModelConnection, RulesetVariable> & ClientDiagnosticsAttribute): Promise<NodePathElement[]> {\r\n await this.onConnection(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 deprecation/deprecation\r\n return result.map(NodePathElement.fromJSON);\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 await this.onConnection(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(requestOptions: ContentDescriptorRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<Descriptor | undefined> {\r\n await this.onConnection(requestOptions.imodel);\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 return Descriptor.fromJSON(result);\r\n }\r\n\r\n /** Retrieves overall content set size. */\r\n public async getContentSetSize(requestOptions: ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<number> {\r\n await this.onConnection(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 /** Retrieves content which consists of a content descriptor and a page of records. */\r\n public async getContent(requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<Content | undefined> {\r\n return (await this.getContentAndSize(requestOptions))?.content;\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 public async getContentAndSize(requestOptions: Paged<ContentRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable>> & ClientDiagnosticsAttribute): Promise<{ content: Content, size: number } | undefined> {\r\n await this.onConnection(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 let descriptor = (requestOptions.descriptor instanceof Descriptor) ? requestOptions.descriptor : undefined;\r\n const result = await buildPagedArrayResponse(options.paging, async (partialPageOptions, requestIndex) => {\r\n if (0 === requestIndex && !descriptor) {\r\n const content = await this._requestsHandler.getPagedContent({ ...rpcOptions, paging: partialPageOptions });\r\n if (content) {\r\n descriptor = Descriptor.fromJSON(content.descriptor);\r\n return content.contentSet;\r\n }\r\n return { total: 0, items: [] };\r\n }\r\n return this._requestsHandler.getPagedContentSet({ ...rpcOptions, paging: partialPageOptions });\r\n });\r\n if (!descriptor)\r\n return undefined;\r\n const items = result.items.map((itemJson) => Item.fromJSON(itemJson)).filter<Item>((item): item is Item => (item !== undefined));\r\n return {\r\n size: result.total,\r\n content: this._localizationHelper.getLocalizedContent(new Content(descriptor, items)),\r\n };\r\n }\r\n\r\n /** Retrieves distinct values of specific field from the content. */\r\n public async getPagedDistinctValues(requestOptions: DistinctValuesRequestOptions<IModelConnection, Descriptor | DescriptorOverrides, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<PagedResponse<DisplayValueGroup>> {\r\n await this.onConnection(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 const result = await buildPagedArrayResponse(requestOptions.paging, async (partialPageOptions) => this._requestsHandler.getPagedDistinctValues({ ...rpcOptions, paging: partialPageOptions }));\r\n return {\r\n ...result,\r\n // eslint-disable-next-line deprecation/deprecation\r\n items: result.items.map(DisplayValueGroup.fromJSON),\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(requestOptions: SingleElementPropertiesRequestOptions<IModelConnection> & ClientDiagnosticsAttribute): Promise<ElementProperties | undefined> {\r\n await this.onConnection(requestOptions.imodel);\r\n const results = await this._requestsHandler.getElementProperties(this.toRpcTokenOptions(requestOptions));\r\n // istanbul ignore if\r\n if (!results)\r\n return undefined;\r\n return this._localizationHelper.getLocalizedElementProperties(results);\r\n }\r\n\r\n /**\r\n * Retrieves content item instance keys.\r\n * @public\r\n */\r\n public async getContentInstanceKeys(requestOptions: ContentInstanceKeysRequestOptions<IModelConnection, KeySet, RulesetVariable> & ClientDiagnosticsAttribute): Promise<{ total: number, items: () => AsyncGenerator<InstanceKey> }> {\r\n await this.onConnection(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 props = {\r\n page: requestOptions.paging,\r\n get: async (page: Required<PageOptions>) => {\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 return createPagedGeneratorResponse(props);\r\n }\r\n\r\n /** Retrieves display label definition of specific item. */\r\n public async getDisplayLabelDefinition(requestOptions: DisplayLabelRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition> {\r\n await this.onConnection(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 getDisplayLabelDefinitions(requestOptions: DisplayLabelsRequestOptions<IModelConnection, InstanceKey> & ClientDiagnosticsAttribute): Promise<LabelDefinition[]> {\r\n await this.onConnection(requestOptions.imodel);\r\n const rpcOptions = this.toRpcTokenOptions({ ...requestOptions });\r\n const result = await buildPagedArrayResponse(undefined, async (partialPageOptions) => {\r\n const partialKeys = (!partialPageOptions.start) ? rpcOptions.keys : rpcOptions.keys.slice(partialPageOptions.start);\r\n return this._requestsHandler.getPagedDisplayLabelDefinitions({ ...rpcOptions, keys: partialKeys });\r\n });\r\n return this._localizationHelper.getLocalizedLabelDefinitions(result.items);\r\n }\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 return descriptorOrOverrides;\r\n};\r\n\r\ninterface PagedGeneratorCreateProps<TPagedResponseItem> {\r\n page: PageOptions | undefined;\r\n get: (pageStart: Required<PageOptions>, requestIndex: number) => Promise<{ total: number, items: TPagedResponseItem[] }>;\r\n}\r\nasync function createPagedGeneratorResponse<TPagedResponseItem>(props: PagedGeneratorCreateProps<TPagedResponseItem>) {\r\n let pageStart = props.page?.start ?? 0;\r\n let pageSize = props.page?.size ?? 0;\r\n let requestIndex = 0;\r\n\r\n const firstPage = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\r\n return {\r\n total: firstPage.total,\r\n async *items() {\r\n let partialResult = firstPage;\r\n while (true) {\r\n for (const item of partialResult.items) {\r\n yield item;\r\n }\r\n\r\n const receivedItemsCount = partialResult.items.length;\r\n if (partialResult.total !== 0 && receivedItemsCount === 0) {\r\n if (pageStart >= partialResult.total)\r\n throw new Error(`Requested page with start index ${pageStart} is out of bounds. Total number of items: ${partialResult.total}`);\r\n throw new Error(\"Paged request returned non zero total count but no items\");\r\n }\r\n\r\n if (pageSize !== 0 && receivedItemsCount >= pageSize || receivedItemsCount >= (partialResult.total - pageStart))\r\n break;\r\n\r\n if (pageSize !== 0)\r\n pageSize -= receivedItemsCount;\r\n pageStart += receivedItemsCount;\r\n\r\n partialResult = await props.get({ start: pageStart, size: pageSize }, requestIndex++);\r\n }\r\n },\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport const buildPagedArrayResponse = async <TItem>(requestedPage: PageOptions | undefined, getter: (page: Required<PageOptions>, requestIndex: number) => Promise<PagedResponse<TItem>>): Promise<PagedResponse<TItem>> => {\r\n try {\r\n const items = new Array<TItem>();\r\n const gen = await createPagedGeneratorResponse({ page: requestedPage, get: getter });\r\n for await (const item of gen.items()) {\r\n items.push(item);\r\n }\r\n return { total: gen.total, items };\r\n } catch {\r\n // FIXME: we should propagate the error...\r\n return { total: 0, items: [] };\r\n }\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 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 = 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"]}
@@ -8,7 +8,10 @@ import { RegisteredRuleset, Ruleset } from "@itwin/presentation-common";
8
8
  * @public
9
9
  */
10
10
  export interface RulesetManager {
11
- /** @alpha */
11
+ /**
12
+ * An event invoked one a ruleset is modified using [[modify]] function.
13
+ * @beta
14
+ */
12
15
  onRulesetModified: BeEvent<(curr: RegisteredRuleset, prev: Ruleset) => void>;
13
16
  /**
14
17
  * Get a ruleset with the specified id.
@@ -20,7 +23,7 @@ export interface RulesetManager {
20
23
  add(ruleset: Ruleset): Promise<RegisteredRuleset>;
21
24
  /**
22
25
  * Modify the given pre-registered ruleset
23
- * @alpha
26
+ * @beta
24
27
  */
25
28
  modify(ruleset: RegisteredRuleset, newRules: Omit<Ruleset, "id">): Promise<RegisteredRuleset>;
26
29
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"RulesetManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/RulesetManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAQ,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa;IACb,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC;IAE7E;;OAEG;IACH,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAA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,gBAAgB,EAAE;gBAC9C,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;gBACf,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;aACP;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,IAAI;YACjC,OAAO;QAET,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { BeEvent, Guid } from \"@itwin/core-bentley\";\r\nimport { RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Presentation ruleset registry.\r\n * @public\r\n */\r\nexport interface RulesetManager {\r\n /** @alpha */\r\n onRulesetModified: BeEvent<(curr: RegisteredRuleset, prev: Ruleset) => void>;\r\n\r\n /**\r\n * Get a ruleset with the specified id.\r\n */\r\n get(id: string): Promise<RegisteredRuleset | undefined>;\r\n\r\n /**\r\n * Register the supplied ruleset\r\n */\r\n add(ruleset: Ruleset): Promise<RegisteredRuleset>;\r\n\r\n /**\r\n * Modify the given pre-registered ruleset\r\n * @alpha\r\n */\r\n modify(ruleset: RegisteredRuleset, newRules: Omit<Ruleset, \"id\">): Promise<RegisteredRuleset>;\r\n\r\n /**\r\n * Unregister the supplied ruleset\r\n */\r\n remove(ruleset: RegisteredRuleset | [string, string]): Promise<boolean>;\r\n\r\n /**\r\n * Remove all rulesets registered in this session.\r\n */\r\n clear(): Promise<void>;\r\n}\r\n\r\n/** @internal */\r\nexport class RulesetManagerImpl implements RulesetManager {\r\n\r\n private _clientRulesets = new Map<string, RegisteredRuleset[]>();\r\n public onRulesetModified = new BeEvent<(curr: RegisteredRuleset, prev: Ruleset) => void>();\r\n\r\n public static create() {\r\n return new RulesetManagerImpl();\r\n }\r\n\r\n /**\r\n * Get a ruleset with the specified id.\r\n */\r\n public async get(id: string): Promise<RegisteredRuleset | undefined> {\r\n const m = this._clientRulesets.get(id);\r\n if (!m)\r\n return undefined;\r\n return m[0];\r\n }\r\n\r\n /**\r\n * Register the supplied ruleset\r\n */\r\n public async add(ruleset: Ruleset): Promise<RegisteredRuleset> {\r\n const registered = new RegisteredRuleset(ruleset, Guid.createValue(), async (r: RegisteredRuleset) => this.remove(r));\r\n if (!this._clientRulesets.has(ruleset.id))\r\n this._clientRulesets.set(ruleset.id, []);\r\n this._clientRulesets.get(ruleset.id)!.push(registered);\r\n return registered;\r\n }\r\n\r\n /**\r\n * Modifies the given pre-registered ruleset\r\n */\r\n public async modify(ruleset: RegisteredRuleset, newRules: Omit<Ruleset, \"id\">): Promise<RegisteredRuleset> {\r\n await this.remove(ruleset);\r\n const modified = await this.add({ ...newRules, id: ruleset.id });\r\n this.onRulesetModified.raiseEvent(modified, ruleset.toJSON());\r\n return modified;\r\n }\r\n\r\n /**\r\n * Unregister the supplied ruleset\r\n */\r\n public async remove(ruleset: RegisteredRuleset | [string, string]): Promise<boolean> {\r\n let rulesetId, uniqueIdentifier: string;\r\n if (Array.isArray(ruleset)) {\r\n rulesetId = ruleset[0];\r\n uniqueIdentifier = ruleset[1];\r\n } else {\r\n rulesetId = ruleset.id;\r\n uniqueIdentifier = ruleset.uniqueIdentifier;\r\n }\r\n\r\n const m = this._clientRulesets.get(rulesetId);\r\n if (!m)\r\n return false;\r\n\r\n let didRemove = false;\r\n for (let i = 0; i < m.length; ++i) {\r\n if (m[i].uniqueIdentifier === uniqueIdentifier) {\r\n m.splice(i, 1);\r\n didRemove = true;\r\n break;\r\n }\r\n }\r\n\r\n return didRemove;\r\n }\r\n\r\n /**\r\n * Remove all rulesets registered in this session.\r\n */\r\n public async clear(): Promise<void> {\r\n if (0 === this._clientRulesets.size)\r\n return;\r\n\r\n this._clientRulesets.clear();\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"RulesetManager.js","sourceRoot":"","sources":["../../../src/presentation-frontend/RulesetManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAW,MAAM,4BAA4B,CAAC;AAwCxE,gBAAgB;AAChB,MAAM,OAAO,kBAAkB;IAA/B;QAEU,oBAAe,GAAG,IAAI,GAAG,EAA+B,CAAC;QAC1D,sBAAiB,GAAG,IAAI,OAAO,EAAoD,CAAC;IA4E7F,CAAC;IA1EQ,MAAM,CAAC,MAAM;QAClB,OAAO,IAAI,kBAAkB,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,EAAU;QACzB,MAAM,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC;YACJ,OAAO,SAAS,CAAC;QACnB,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACd,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,GAAG,CAAC,OAAgB;QAC/B,MAAM,UAAU,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAoB,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACtH,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACvC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAE,CAAC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aACP;SACF;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,IAAI;YACjC,OAAO;QAET,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { BeEvent, Guid } from \"@itwin/core-bentley\";\r\nimport { RegisteredRuleset, Ruleset } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Presentation ruleset registry.\r\n * @public\r\n */\r\nexport interface RulesetManager {\r\n /**\r\n * An event invoked one a ruleset is modified using [[modify]] function.\r\n * @beta\r\n */\r\n onRulesetModified: BeEvent<(curr: RegisteredRuleset, prev: Ruleset) => void>;\r\n\r\n /**\r\n * Get a ruleset with the specified id.\r\n */\r\n get(id: string): Promise<RegisteredRuleset | undefined>;\r\n\r\n /**\r\n * Register the supplied ruleset\r\n */\r\n add(ruleset: Ruleset): Promise<RegisteredRuleset>;\r\n\r\n /**\r\n * Modify the given pre-registered ruleset\r\n * @beta\r\n */\r\n modify(ruleset: RegisteredRuleset, newRules: Omit<Ruleset, \"id\">): Promise<RegisteredRuleset>;\r\n\r\n /**\r\n * Unregister the supplied ruleset\r\n */\r\n remove(ruleset: RegisteredRuleset | [string, string]): Promise<boolean>;\r\n\r\n /**\r\n * Remove all rulesets registered in this session.\r\n */\r\n clear(): Promise<void>;\r\n}\r\n\r\n/** @internal */\r\nexport class RulesetManagerImpl implements RulesetManager {\r\n\r\n private _clientRulesets = new Map<string, RegisteredRuleset[]>();\r\n public onRulesetModified = new BeEvent<(curr: RegisteredRuleset, prev: Ruleset) => void>();\r\n\r\n public static create() {\r\n return new RulesetManagerImpl();\r\n }\r\n\r\n /**\r\n * Get a ruleset with the specified id.\r\n */\r\n public async get(id: string): Promise<RegisteredRuleset | undefined> {\r\n const m = this._clientRulesets.get(id);\r\n if (!m)\r\n return undefined;\r\n return m[0];\r\n }\r\n\r\n /**\r\n * Register the supplied ruleset\r\n */\r\n public async add(ruleset: Ruleset): Promise<RegisteredRuleset> {\r\n const registered = new RegisteredRuleset(ruleset, Guid.createValue(), async (r: RegisteredRuleset) => this.remove(r));\r\n if (!this._clientRulesets.has(ruleset.id))\r\n this._clientRulesets.set(ruleset.id, []);\r\n this._clientRulesets.get(ruleset.id)!.push(registered);\r\n return registered;\r\n }\r\n\r\n /**\r\n * Modifies the given pre-registered ruleset\r\n */\r\n public async modify(ruleset: RegisteredRuleset, newRules: Omit<Ruleset, \"id\">): Promise<RegisteredRuleset> {\r\n await this.remove(ruleset);\r\n const modified = await this.add({ ...newRules, id: ruleset.id });\r\n this.onRulesetModified.raiseEvent(modified, ruleset.toJSON());\r\n return modified;\r\n }\r\n\r\n /**\r\n * Unregister the supplied ruleset\r\n */\r\n public async remove(ruleset: RegisteredRuleset | [string, string]): Promise<boolean> {\r\n let rulesetId, uniqueIdentifier: string;\r\n if (Array.isArray(ruleset)) {\r\n rulesetId = ruleset[0];\r\n uniqueIdentifier = ruleset[1];\r\n } else {\r\n rulesetId = ruleset.id;\r\n uniqueIdentifier = ruleset.uniqueIdentifier;\r\n }\r\n\r\n const m = this._clientRulesets.get(rulesetId);\r\n if (!m)\r\n return false;\r\n\r\n let didRemove = false;\r\n for (let i = 0; i < m.length; ++i) {\r\n if (m[i].uniqueIdentifier === uniqueIdentifier) {\r\n m.splice(i, 1);\r\n didRemove = true;\r\n break;\r\n }\r\n }\r\n\r\n return didRemove;\r\n }\r\n\r\n /**\r\n * Remove all rulesets registered in this session.\r\n */\r\n public async clear(): Promise<void> {\r\n if (0 === this._clientRulesets.size)\r\n return;\r\n\r\n this._clientRulesets.clear();\r\n }\r\n\r\n}\r\n"]}
@@ -12,13 +12,28 @@ export interface NodeIdentifier {
12
12
  id: string;
13
13
  key: NodeKey;
14
14
  }
15
- /** @internal */
15
+ /**
16
+ * @internal
17
+ */
18
+ export interface NodeState {
19
+ isExpanded?: boolean;
20
+ instanceFilter?: string;
21
+ }
22
+ /**
23
+ * The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
24
+ * just the state changes to the backend as soon as component sends in a new hierarchy state.
25
+ *
26
+ * @internal
27
+ */
16
28
  export declare class StateTracker {
17
- private _expandedHierarchies;
29
+ private _hierarchyStates;
18
30
  private _ipcRequestsHandler;
19
31
  constructor(ipcRequestsHandler: IpcRequestsHandler);
20
32
  private updateHierarchyStateIfNeeded;
21
33
  onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string): Promise<void>;
22
- onExpandedNodesChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, expandedNodes: NodeIdentifier[]): Promise<void>;
34
+ onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{
35
+ node: NodeIdentifier | undefined;
36
+ state: NodeState;
37
+ }>): Promise<void>;
23
38
  }
24
39
  //# sourceMappingURL=StateTracker.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"StateTracker.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,OAAO,CAAC;CACd;AAcD,gBAAgB;AAChB,qBAAa,YAAY;IACvB,OAAO,CAAC,oBAAoB,CAAiC;IAC7D,OAAO,CAAC,mBAAmB,CAAqB;gBAEpC,kBAAkB,EAAE,kBAAkB;YAKpC,4BAA4B;IAM7B,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAsB/E,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE;CAwCnI"}
1
+ {"version":3,"file":"StateTracker.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAgBD;;;;;GAKG;AACH,qBAAa,YAAY;IAEvB,OAAO,CAAC,gBAAgB,CAAwD;IAChF,OAAO,CAAC,mBAAmB,CAAqB;gBAEpC,kBAAkB,EAAE,kBAAkB;YAKpC,4BAA4B;IAM7B,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAmB/E,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;CA+DrL"}
@@ -5,67 +5,122 @@
5
5
  /** @packageDocumentation
6
6
  * @module Core
7
7
  */
8
- /** @internal */
8
+ import { using } from "@itwin/core-bentley";
9
+ /**
10
+ * The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
11
+ * just the state changes to the backend as soon as component sends in a new hierarchy state.
12
+ *
13
+ * @internal
14
+ */
9
15
  export class StateTracker {
10
16
  constructor(ipcRequestsHandler) {
11
17
  this._ipcRequestsHandler = ipcRequestsHandler;
12
- this._expandedHierarchies = new Map();
18
+ this._hierarchyStates = new Map();
13
19
  }
14
- async updateHierarchyStateIfNeeded(imodelKey, rulesetId, changeType, nodeKeys) {
15
- if (nodeKeys.length === 0)
20
+ async updateHierarchyStateIfNeeded(imodelKey, rulesetId, stateChanges) {
21
+ if (stateChanges.length === 0)
16
22
  return;
17
- await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, changeType, nodeKeys });
23
+ await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, stateChanges });
18
24
  }
19
25
  async onHierarchyClosed(imodel, rulesetId, sourceId) {
20
- const hierarchy = this._expandedHierarchies.get(rulesetId);
21
- if (!hierarchy)
26
+ const hierarchyState = this._hierarchyStates.get(rulesetId);
27
+ if (!hierarchyState)
22
28
  return;
23
- const removedKeys = [];
24
- for (const [nodeId, expandedNode] of hierarchy) {
25
- expandedNode.expandedIn.delete(sourceId);
26
- // if there are other sources that have this node expanded leave it.
27
- if (expandedNode.expandedIn.size !== 0)
28
- continue;
29
- hierarchy.delete(nodeId);
30
- removedKeys.push(expandedNode.key);
31
- }
32
- if (hierarchy.size === 0)
33
- this._expandedHierarchies.delete(rulesetId);
34
- await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, "nodesCollapsed", removedKeys);
29
+ const stateChanges = [];
30
+ hierarchyState.forEach((entry) => {
31
+ if (!entry.states.has(sourceId)) {
32
+ // the node has no state for this source - nothing to do
33
+ return;
34
+ }
35
+ using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {
36
+ entry.states.delete(sourceId);
37
+ });
38
+ });
39
+ await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);
35
40
  }
36
- async onExpandedNodesChanged(imodel, rulesetId, sourceId, expandedNodes) {
37
- let hierarchy = this._expandedHierarchies.get(rulesetId);
38
- if (expandedNodes.length === 0 && !hierarchy)
39
- return;
40
- if (!hierarchy) {
41
- hierarchy = new Map();
42
- this._expandedHierarchies.set(rulesetId, hierarchy);
41
+ async onHierarchyStateChanged(imodel, rulesetId, sourceId, newHierarchyState) {
42
+ let hierarchyState = this._hierarchyStates.get(rulesetId);
43
+ if (!hierarchyState) {
44
+ if (newHierarchyState.length === 0)
45
+ return;
46
+ hierarchyState = new Map();
47
+ this._hierarchyStates.set(rulesetId, hierarchyState);
43
48
  }
44
- const removedKeys = [];
45
- const addedKeys = [];
46
- for (const [key, existingNode] of hierarchy) {
47
- // existing node is in new expanded nodes list. Add current source
48
- if (expandedNodes.find((expandedNode) => expandedNode.id === key)) {
49
- existingNode.expandedIn.add(sourceId);
50
- continue;
49
+ const handledNodeIds = new Set();
50
+ const stateChanges = [];
51
+ // step 1: walk over new state and report all changes
52
+ newHierarchyState.forEach(({ node, state }) => {
53
+ const nodeId = node === null || node === void 0 ? void 0 : node.id;
54
+ const nodeKey = node === null || node === void 0 ? void 0 : node.key;
55
+ const existingNodeEntry = hierarchyState.get(nodeId);
56
+ if (existingNodeEntry) {
57
+ using(new MergedNodeStateChangeReporter(existingNodeEntry, stateChanges), (_) => {
58
+ existingNodeEntry.states.set(sourceId, state);
59
+ });
60
+ }
61
+ else {
62
+ hierarchyState.set(nodeId, { key: nodeKey, states: new Map([[sourceId, state]]) });
63
+ stateChanges.push({ ...calculateMergedNodeState([state].values()), nodeKey });
64
+ }
65
+ handledNodeIds.add(nodeId);
66
+ });
67
+ // step 2: walk over old state and remove all state that's not in the new state
68
+ const erasedNodeIds = new Set();
69
+ hierarchyState.forEach((entry, nodeId) => {
70
+ if (handledNodeIds.has(nodeId)) {
71
+ // the node was handled with the new state - nothing to do here
72
+ return;
73
+ }
74
+ if (!entry.states.has(sourceId)) {
75
+ // the node had no state for this source, so it's not affected by this report
76
+ return;
51
77
  }
52
- // node was not found in expanded nodes list. Remove current source
53
- existingNode.expandedIn.delete(sourceId);
54
- if (existingNode.expandedIn.size !== 0)
55
- continue;
56
- removedKeys.push(existingNode.key);
57
- hierarchy.delete(key);
78
+ using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {
79
+ entry.states.delete(sourceId);
80
+ });
81
+ // istanbul ignore next
82
+ if (entry.states.size === 0) {
83
+ // there are no more components holding state for this node
84
+ erasedNodeIds.add(nodeId);
85
+ }
86
+ });
87
+ // step 3: cleanup erased node ids and possibly the whole hierarchy state
88
+ for (const nodeId of erasedNodeIds) {
89
+ hierarchyState.delete(nodeId);
58
90
  }
59
- // add any new nodes that were not in expanded nodes hierarchy already
60
- for (const expandedNode of expandedNodes) {
61
- const existingNode = hierarchy.get(expandedNode.id);
62
- if (existingNode)
63
- continue;
64
- hierarchy.set(expandedNode.id, { key: expandedNode.key, expandedIn: new Set([sourceId]) });
65
- addedKeys.push(expandedNode.key);
91
+ if (hierarchyState.size === 0)
92
+ this._hierarchyStates.delete(rulesetId);
93
+ // finally, report
94
+ await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);
95
+ }
96
+ }
97
+ function calculateMergedNodeState(perComponentStates) {
98
+ const merged = {};
99
+ for (const state of perComponentStates) {
100
+ if (state.isExpanded)
101
+ merged.isExpanded = true;
102
+ if (state.instanceFilter) {
103
+ if (!merged.instanceFilters)
104
+ merged.instanceFilters = [state.instanceFilter];
105
+ else if (!merged.instanceFilters.includes(state.instanceFilter))
106
+ merged.instanceFilters.push(state.instanceFilter);
66
107
  }
67
- await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, "nodesCollapsed", removedKeys);
68
- await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, "nodesExpanded", addedKeys);
108
+ }
109
+ return merged;
110
+ }
111
+ class MergedNodeStateChangeReporter {
112
+ constructor(entry, outStateChanges) {
113
+ this._entry = entry;
114
+ this._stateBefore = calculateMergedNodeState(this._entry.states.values());
115
+ this._outStateChanges = outStateChanges;
116
+ }
117
+ dispose() {
118
+ var _a, _b, _c, _d;
119
+ const stateAfter = calculateMergedNodeState(this._entry.states.values());
120
+ const expandedFlagsDiffer = !!stateAfter.isExpanded !== !!this._stateBefore.isExpanded;
121
+ const instanceFiltersDiffer = ((_b = (_a = stateAfter.instanceFilters) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) !== ((_d = (_c = this._stateBefore.instanceFilters) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0);
122
+ if (expandedFlagsDiffer || instanceFiltersDiffer)
123
+ this._outStateChanges.push({ ...stateAfter, nodeKey: this._entry.key });
69
124
  }
70
125
  }
71
126
  //# sourceMappingURL=StateTracker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StateTracker.js","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AA2BH,gBAAgB;AAChB,MAAM,OAAO,YAAY;IAIvB,YAAY,kBAAsC;QAChD,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;QAC9C,IAAI,CAAC,oBAAoB,GAAG,IAAI,GAAG,EAA6B,CAAC;IACnE,CAAC;IAEO,KAAK,CAAC,4BAA4B,CAAC,SAAiB,EAAE,SAAiB,EAAE,UAA8C,EAAE,QAAmB;QAClJ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YACvB,OAAO;QACT,MAAM,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtG,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,MAAwB,EAAE,SAAiB,EAAE,QAAgB;QAC1F,MAAM,SAAS,GAAG,IAAI,C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,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE;gBACjE,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBACtC,SAAS;aACV;YAED,mEAAmE;YACnE,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC;gBACpC,SAAS;YAEX,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YACnC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACvB;QAED,sEAAsE;QACtE,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;YACxC,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YACpD,IAAI,YAAY;gBACd,SAAS;YAEX,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,GAAG,CAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;YACnG,SAAS,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;SAClC;QAED,MAAM,IAAI,CAAC,4BAA4B,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,gBAAgB,EAAE,WAAW,CAAC,CAAC;QAC9F,MAAM,IAAI,CAAC,4BAA4B,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;IAC7F,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { NodeKey } from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\n\r\n/**\r\n * Data structure that describes information used by [[StateTracker]] to identify node.\r\n * @internal\r\n */\r\nexport interface NodeIdentifier {\r\n id: string;\r\n key: NodeKey;\r\n}\r\n\r\n/**\r\n * Data structure that describes expanded node.\r\n */\r\ninterface ExpandedNode {\r\n key: NodeKey;\r\n /** Set of source ids in which this node is expanded. */\r\n expandedIn: Set<string>;\r\n}\r\n\r\n/** Maps node ids to expanded nodes. */\r\ntype ExpandedHierarchy = Map<string, ExpandedNode>;\r\n\r\n/** @internal */\r\nexport class StateTracker {\r\n private _expandedHierarchies: Map<string, ExpandedHierarchy>;\r\n private _ipcRequestsHandler: IpcRequestsHandler;\r\n\r\n constructor(ipcRequestsHandler: IpcRequestsHandler) {\r\n this._ipcRequestsHandler = ipcRequestsHandler;\r\n this._expandedHierarchies = new Map<string, ExpandedHierarchy>();\r\n }\r\n\r\n private async updateHierarchyStateIfNeeded(imodelKey: string, rulesetId: string, changeType: \"nodesExpanded\" | \"nodesCollapsed\", nodeKeys: NodeKey[]) {\r\n if (nodeKeys.length === 0)\r\n return;\r\n await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, changeType, nodeKeys });\r\n }\r\n\r\n public async onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string) {\r\n const hierarchy = this._expandedHierarchies.get(rulesetId);\r\n if (!hierarchy)\r\n return;\r\n\r\n const removedKeys: NodeKey[] = [];\r\n for (const [nodeId, expandedNode] of hierarchy) {\r\n expandedNode.expandedIn.delete(sourceId);\r\n // if there are other sources that have this node expanded leave it.\r\n if (expandedNode.expandedIn.size !== 0)\r\n continue;\r\n\r\n hierarchy.delete(nodeId);\r\n removedKeys.push(expandedNode.key);\r\n }\r\n\r\n if (hierarchy.size === 0)\r\n this._expandedHierarchies.delete(rulesetId);\r\n\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, \"nodesCollapsed\", removedKeys);\r\n }\r\n\r\n public async onExpandedNodesChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, expandedNodes: NodeIdentifier[]) {\r\n let hierarchy = this._expandedHierarchies.get(rulesetId);\r\n if (expandedNodes.length === 0 && !hierarchy)\r\n return;\r\n if (!hierarchy) {\r\n hierarchy = new Map<string, ExpandedNode>();\r\n this._expandedHierarchies.set(rulesetId, hierarchy);\r\n }\r\n\r\n const removedKeys: NodeKey[] = [];\r\n const addedKeys: NodeKey[] = [];\r\n for (const [key, existingNode] of hierarchy) {\r\n // existing node is in new expanded nodes list. Add current source\r\n if (expandedNodes.find((expandedNode) => expandedNode.id === key)) {\r\n existingNode.expandedIn.add(sourceId);\r\n continue;\r\n }\r\n\r\n // node was not found in expanded nodes list. Remove current source\r\n existingNode.expandedIn.delete(sourceId);\r\n if (existingNode.expandedIn.size !== 0)\r\n continue;\r\n\r\n removedKeys.push(existingNode.key);\r\n hierarchy.delete(key);\r\n }\r\n\r\n // add any new nodes that were not in expanded nodes hierarchy already\r\n for (const expandedNode of expandedNodes) {\r\n const existingNode = hierarchy.get(expandedNode.id);\r\n if (existingNode)\r\n continue;\r\n\r\n hierarchy.set(expandedNode.id, { key: expandedNode.key, expandedIn: new Set<string>([sourceId]) });\r\n addedKeys.push(expandedNode.key);\r\n }\r\n\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, \"nodesCollapsed\", removedKeys);\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, \"nodesExpanded\", addedKeys);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"StateTracker.js","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAe,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAoCzD;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAKvB,YAAY,kBAAsC;Q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xB,IAAI,CAAC,MAAM,CAAC,eAAe;gBACzB,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;iBAC7C,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC;gBAC7D,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;SACrD;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,6BAA6B;IAIjC,YAAmB,KAAsB,EAAE,eAAoC;QAC7E,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,YAAY,GAAG,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IACM,OAAO;;QACZ,MAAM,UAAU,GAAG,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACzE,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACvF,MAAM,qBAAqB,GAAG,CAAC,MAAA,MAAA,UAAU,CAAC,eAAe,0CAAE,MAAM,mCAAI,CAAC,CAAC,KAAK,CAAC,MAAA,MAAA,IAAI,CAAC,YAAY,CAAC,eAAe,0CAAE,MAAM,mCAAI,CAAC,CAAC,CAAC;QAC7H,IAAI,mBAAmB,IAAI,qBAAqB;YAC9C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { NodeKey } from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\n\r\n/**\r\n * Data structure that describes information used by [[StateTracker]] to identify node.\r\n * @internal\r\n */\r\nexport interface NodeIdentifier {\r\n id: string;\r\n key: NodeKey;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface NodeState {\r\n isExpanded?: boolean;\r\n instanceFilter?: string;\r\n}\r\n\r\ninterface MergedNodeState {\r\n isExpanded?: boolean;\r\n instanceFilters?: string[];\r\n}\r\n\r\ninterface ReportedNodeState extends MergedNodeState {\r\n nodeKey: NodeKey | undefined;\r\n}\r\n\r\ninterface NodeStatesEntry {\r\n key: NodeKey | undefined;\r\n states: Map<string, NodeState>; // per-component node state\r\n}\r\n\r\n/**\r\n * The tracker stores up-to-date UI state of the hierarchies on the frontend and reports\r\n * just the state changes to the backend as soon as component sends in a new hierarchy state.\r\n *\r\n * @internal\r\n */\r\nexport class StateTracker {\r\n // Ruleset ID => Node ID => Node state info\r\n private _hierarchyStates: Map<string, Map<string | undefined, NodeStatesEntry>>;\r\n private _ipcRequestsHandler: IpcRequestsHandler;\r\n\r\n constructor(ipcRequestsHandler: IpcRequestsHandler) {\r\n this._ipcRequestsHandler = ipcRequestsHandler;\r\n this._hierarchyStates = new Map();\r\n }\r\n\r\n private async updateHierarchyStateIfNeeded(imodelKey: string, rulesetId: string, stateChanges: ReportedNodeState[]) {\r\n if (stateChanges.length === 0)\r\n return;\r\n await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, stateChanges });\r\n }\r\n\r\n public async onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string) {\r\n const hierarchyState = this._hierarchyStates.get(rulesetId);\r\n if (!hierarchyState)\r\n return;\r\n\r\n const stateChanges: ReportedNodeState[] = [];\r\n hierarchyState.forEach((entry) => {\r\n if (!entry.states.has(sourceId)) {\r\n // the node has no state for this source - nothing to do\r\n return;\r\n }\r\n using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {\r\n entry.states.delete(sourceId);\r\n });\r\n });\r\n\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);\r\n }\r\n\r\n public async onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{ node: NodeIdentifier | undefined, state: NodeState }>) {\r\n let hierarchyState = this._hierarchyStates.get(rulesetId);\r\n if (!hierarchyState) {\r\n if (newHierarchyState.length === 0)\r\n return;\r\n\r\n hierarchyState = new Map();\r\n this._hierarchyStates.set(rulesetId, hierarchyState);\r\n }\r\n\r\n const handledNodeIds = new Set<string | undefined>();\r\n const stateChanges: ReportedNodeState[] = [];\r\n\r\n // step 1: walk over new state and report all changes\r\n newHierarchyState.forEach(({ node, state }) => {\r\n const nodeId = node?.id;\r\n const nodeKey = node?.key;\r\n const existingNodeEntry = hierarchyState!.get(nodeId);\r\n if (existingNodeEntry) {\r\n using(new MergedNodeStateChangeReporter(existingNodeEntry, stateChanges), (_) => {\r\n existingNodeEntry.states.set(sourceId, state);\r\n });\r\n } else {\r\n hierarchyState!.set(nodeId, { key: nodeKey, states: new Map([[sourceId, state]]) });\r\n stateChanges.push({ ...calculateMergedNodeState([state].values()), nodeKey });\r\n }\r\n handledNodeIds.add(nodeId);\r\n });\r\n\r\n // step 2: walk over old state and remove all state that's not in the new state\r\n const erasedNodeIds = new Set<string | undefined>();\r\n hierarchyState.forEach((entry, nodeId) => {\r\n if (handledNodeIds.has(nodeId)) {\r\n // the node was handled with the new state - nothing to do here\r\n return;\r\n }\r\n\r\n if (!entry.states.has(sourceId)) {\r\n // the node had no state for this source, so it's not affected by this report\r\n return;\r\n }\r\n\r\n using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {\r\n entry.states.delete(sourceId);\r\n });\r\n\r\n // istanbul ignore next\r\n if (entry.states.size === 0) {\r\n // there are no more components holding state for this node\r\n erasedNodeIds.add(nodeId);\r\n }\r\n });\r\n\r\n // step 3: cleanup erased node ids and possibly the whole hierarchy state\r\n for (const nodeId of erasedNodeIds) {\r\n hierarchyState.delete(nodeId);\r\n }\r\n if (hierarchyState.size === 0)\r\n this._hierarchyStates.delete(rulesetId);\r\n\r\n // finally, report\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);\r\n }\r\n}\r\n\r\nfunction calculateMergedNodeState(perComponentStates: IterableIterator<NodeState>): MergedNodeState {\r\n const merged: MergedNodeState = {};\r\n for (const state of perComponentStates) {\r\n if (state.isExpanded)\r\n merged.isExpanded = true;\r\n if (state.instanceFilter) {\r\n if (!merged.instanceFilters)\r\n merged.instanceFilters = [state.instanceFilter];\r\n else if (!merged.instanceFilters.includes(state.instanceFilter))\r\n merged.instanceFilters.push(state.instanceFilter);\r\n }\r\n }\r\n return merged;\r\n}\r\n\r\nclass MergedNodeStateChangeReporter implements IDisposable {\r\n private _entry: NodeStatesEntry;\r\n private _stateBefore: MergedNodeState;\r\n private _outStateChanges: ReportedNodeState[];\r\n public constructor(entry: NodeStatesEntry, outStateChanges: ReportedNodeState[]) {\r\n this._entry = entry;\r\n this._stateBefore = calculateMergedNodeState(this._entry.states.values());\r\n this._outStateChanges = outStateChanges;\r\n }\r\n public dispose() {\r\n const stateAfter = calculateMergedNodeState(this._entry.states.values());\r\n const expandedFlagsDiffer = !!stateAfter.isExpanded !== !!this._stateBefore.isExpanded;\r\n const instanceFiltersDiffer = (stateAfter.instanceFilters?.length ?? 0) !== (this._stateBefore.instanceFilters?.length ?? 0);\r\n if (expandedFlagsDiffer || instanceFiltersDiffer)\r\n this._outStateChanges.push({ ...stateAfter, nodeKey: this._entry.key });\r\n }\r\n}\r\n"]}
@@ -54,7 +54,7 @@ export declare function createSelectionScopeProps(scope: SelectionScopeProps | S
54
54
  * Determines the scope id
55
55
  * @param scope Selection scope
56
56
  * @public
57
- * @deprecated This is an internal utility that should've never become public.
57
+ * @deprecated in 3.x. This is an internal utility that should've never become public.
58
58
  */
59
59
  export declare function getScopeId(scope: SelectionScope | string | undefined): string;
60
60
  //# sourceMappingURL=SelectionScopesManager.d.ts.map
@@ -77,7 +77,7 @@ export function createSelectionScopeProps(scope) {
77
77
  * Determines the scope id
78
78
  * @param scope Selection scope
79
79
  * @public
80
- * @deprecated This is an internal utility that should've never become public.
80
+ * @deprecated in 3.x. This is an internal utility that should've never become public.
81
81
  */
82
82
  // istanbul ignore next
83
83
  export function getScopeId(scope) {
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionScopesManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionScopesManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAA2D,MAAM,4BAA4B,CAAC;AActI;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAMjC,YAAmB,KAAkC;QACnD,IAAI,CAAC,mBAAmB,GAAG,KAAK,CAAC,kBAAkB,CAAC;QACpD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACpF,CAAC;IAED,wBAAwB;IACxB,IAAW,YAAY,KAAK,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAEvD,2CAA2C;IAC3C,IAAW,WAAW,KAAK,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACtD,IAAW,WAAW,CAAC,KAAgE,IAAI,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC;IAEvH;;;;OAIG;IACI,KAAK,CAAC,kBAAkB,CAAC,MAAwB,E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,EAAE,QAAQ,CAAC,CAAC;YACtG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;SAC7I;QACD,MAAM,SAAS,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7E,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAgE;IACxG,IAAI,CAAC,KAAK;QACR,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAC3B,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;IACvB,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,uBAAuB;AACvB,MAAM,UAAU,UAAU,CAAC,KAA0C;IACnE,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Id64Arg } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { DEFAULT_KEYS_BATCH_SIZE, KeySet, RpcRequestsHandler, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Properties for creating [[SelectionScopesManager]].\r\n * @public\r\n */\r\nexport interface SelectionScopesManagerProps {\r\n /** RPC handler to use for requesting selection scopes */\r\n rpcRequestsHandler: RpcRequestsHandler;\r\n\r\n /** Provider of active locale to use for localizing scopes */\r\n localeProvider?: () => string | undefined;\r\n}\r\n\r\n/**\r\n * A manager that knows available [selection scopes]($docs/presentation/unified-selection/index#selection-scopes)\r\n * and can compute logical selection based on element IDs and selection scope.\r\n *\r\n * @public\r\n */\r\nexport class SelectionScopesManager {\r\n\r\n private _rpcRequestsHandler: RpcRequestsHandler;\r\n private _getLocale: () => string | undefined;\r\n private _activeScope: SelectionScopeProps | SelectionScope | string | undefined;\r\n\r\n public constructor(props: SelectionScopesManagerProps) {\r\n this._rpcRequestsHandler = props.rpcRequestsHandler;\r\n this._getLocale = props.localeProvider ? props.localeProvider : (() => undefined);\r\n }\r\n\r\n /** Get active locale */\r\n public get activeLocale() { return this._getLocale(); }\r\n\r\n /** The active selection scope or its id */\r\n public get activeScope() { return this._activeScope; }\r\n public set activeScope(scope: SelectionScopeProps | SelectionScope | string | undefined) { this._activeScope = scope; }\r\n\r\n /**\r\n * Get available selection scopes.\r\n * @param imodel The iModel to get selection scopes for\r\n * @param locale Optional locale to use when localizing scopes' label and description\r\n */\r\n public async getSelectionScopes(imodel: IModelConnection, locale?: string): Promise<SelectionScope[]> {\r\n if (!locale)\r\n locale = this._getLocale();\r\n return this._rpcRequestsHandler.getSelectionScopes({ imodel: imodel.getRpcProps(), locale });\r\n }\r\n\r\n /**\r\n * Computes keys that need to be added to logical selection based on provided selection scope.\r\n * @param ids Element IDs to compute selection for\r\n * @param scope Selection scope to apply\r\n */\r\n public async computeSelection(imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string): Promise<KeySet> {\r\n const scopeProps = createSelectionScopeProps(scope);\r\n\r\n // convert ids input to array\r\n if (typeof ids === \"string\")\r\n ids = [ids];\r\n else if (ids instanceof Set)\r\n ids = [...ids];\r\n\r\n // compute selection in batches to avoid HTTP 413\r\n const keys = new KeySet();\r\n const batchSize = DEFAULT_KEYS_BATCH_SIZE;\r\n const batchesCount = Math.ceil(ids.length / batchSize);\r\n const batchKeyPromises = [];\r\n for (let batchIndex = 0; batchIndex < batchesCount; ++batchIndex) {\r\n const batchStart = batchSize * batchIndex;\r\n const batchEnd = (batchStart + batchSize > ids.length) ? ids.length : (batchStart + batchSize);\r\n const batchIds = (0 === batchIndex && ids.length <= batchEnd) ? ids : ids.slice(batchStart, batchEnd);\r\n batchKeyPromises.push(this._rpcRequestsHandler.computeSelection({ imodel: imodel.getRpcProps(), elementIds: batchIds, scope: scopeProps }));\r\n }\r\n const batchKeys = (await Promise.all(batchKeyPromises)).map(KeySet.fromJSON);\r\n batchKeys.forEach((bk) => keys.add(bk));\r\n return keys;\r\n }\r\n}\r\n\r\n/**\r\n * Normalizes given scope options and returns [[ComputeSelectionScopeProps]] that can be used for\r\n * calculating selection with scope.\r\n *\r\n * @internal\r\n */\r\nexport function createSelectionScopeProps(scope: SelectionScopeProps | SelectionScope | string | undefined): SelectionScopeProps {\r\n if (!scope)\r\n return { id: \"element\" };\r\n if (typeof scope === \"string\")\r\n return { id: scope };\r\n return scope;\r\n}\r\n\r\n/**\r\n * Determines the scope id\r\n * @param scope Selection scope\r\n * @public\r\n * @deprecated This is an internal utility that should've never become public.\r\n */\r\n// istanbul ignore next\r\nexport function getScopeId(scope: SelectionScope | string | undefined): string {\r\n return createSelectionScopeProps(scope).id;\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionScopesManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionScopesManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAA2D,MAAM,4BAA4B,CAAC;AActI;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAMjC,YAAmB,KAAkC;QACnD,IAAI,CAAC,mBAAm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,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,uBAAuB;AACvB,MAAM,UAAU,UAAU,CAAC,KAA0C;IACnE,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Id64Arg } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { DEFAULT_KEYS_BATCH_SIZE, KeySet, RpcRequestsHandler, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Properties for creating [[SelectionScopesManager]].\r\n * @public\r\n */\r\nexport interface SelectionScopesManagerProps {\r\n /** RPC handler to use for requesting selection scopes */\r\n rpcRequestsHandler: RpcRequestsHandler;\r\n\r\n /** Provider of active locale to use for localizing scopes */\r\n localeProvider?: () => string | undefined;\r\n}\r\n\r\n/**\r\n * A manager that knows available [selection scopes]($docs/presentation/unified-selection/index#selection-scopes)\r\n * and can compute logical selection based on element IDs and selection scope.\r\n *\r\n * @public\r\n */\r\nexport class SelectionScopesManager {\r\n\r\n private _rpcRequestsHandler: RpcRequestsHandler;\r\n private _getLocale: () => string | undefined;\r\n private _activeScope: SelectionScopeProps | SelectionScope | string | undefined;\r\n\r\n public constructor(props: SelectionScopesManagerProps) {\r\n this._rpcRequestsHandler = props.rpcRequestsHandler;\r\n this._getLocale = props.localeProvider ? props.localeProvider : (() => undefined);\r\n }\r\n\r\n /** Get active locale */\r\n public get activeLocale() { return this._getLocale(); }\r\n\r\n /** The active selection scope or its id */\r\n public get activeScope() { return this._activeScope; }\r\n public set activeScope(scope: SelectionScopeProps | SelectionScope | string | undefined) { this._activeScope = scope; }\r\n\r\n /**\r\n * Get available selection scopes.\r\n * @param imodel The iModel to get selection scopes for\r\n * @param locale Optional locale to use when localizing scopes' label and description\r\n */\r\n public async getSelectionScopes(imodel: IModelConnection, locale?: string): Promise<SelectionScope[]> {\r\n if (!locale)\r\n locale = this._getLocale();\r\n return this._rpcRequestsHandler.getSelectionScopes({ imodel: imodel.getRpcProps(), locale });\r\n }\r\n\r\n /**\r\n * Computes keys that need to be added to logical selection based on provided selection scope.\r\n * @param ids Element IDs to compute selection for\r\n * @param scope Selection scope to apply\r\n */\r\n public async computeSelection(imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string): Promise<KeySet> {\r\n const scopeProps = createSelectionScopeProps(scope);\r\n\r\n // convert ids input to array\r\n if (typeof ids === \"string\")\r\n ids = [ids];\r\n else if (ids instanceof Set)\r\n ids = [...ids];\r\n\r\n // compute selection in batches to avoid HTTP 413\r\n const keys = new KeySet();\r\n const batchSize = DEFAULT_KEYS_BATCH_SIZE;\r\n const batchesCount = Math.ceil(ids.length / batchSize);\r\n const batchKeyPromises = [];\r\n for (let batchIndex = 0; batchIndex < batchesCount; ++batchIndex) {\r\n const batchStart = batchSize * batchIndex;\r\n const batchEnd = (batchStart + batchSize > ids.length) ? ids.length : (batchStart + batchSize);\r\n const batchIds = (0 === batchIndex && ids.length <= batchEnd) ? ids : ids.slice(batchStart, batchEnd);\r\n batchKeyPromises.push(this._rpcRequestsHandler.computeSelection({ imodel: imodel.getRpcProps(), elementIds: batchIds, scope: scopeProps }));\r\n }\r\n const batchKeys = (await Promise.all(batchKeyPromises)).map(KeySet.fromJSON);\r\n batchKeys.forEach((bk) => keys.add(bk));\r\n return keys;\r\n }\r\n}\r\n\r\n/**\r\n * Normalizes given scope options and returns [[ComputeSelectionScopeProps]] that can be used for\r\n * calculating selection with scope.\r\n *\r\n * @internal\r\n */\r\nexport function createSelectionScopeProps(scope: SelectionScopeProps | SelectionScope | string | undefined): SelectionScopeProps {\r\n if (!scope)\r\n return { id: \"element\" };\r\n if (typeof scope === \"string\")\r\n return { id: scope };\r\n return scope;\r\n}\r\n\r\n/**\r\n * Determines the scope id\r\n * @param scope Selection scope\r\n * @public\r\n * @deprecated in 3.x. This is an internal utility that should've never become public.\r\n */\r\n// istanbul ignore next\r\nexport function getScopeId(scope: SelectionScope | string | undefined): string {\r\n return createSelectionScopeProps(scope).id;\r\n}\r\n"]}