@itwin/presentation-frontend 4.0.0-dev.4 → 4.0.0-dev.40

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 (48) hide show
  1. package/CHANGELOG.md +17 -3
  2. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +1 -1
  3. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  4. package/lib/cjs/presentation-frontend/Presentation.d.ts +0 -2
  5. package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
  6. package/lib/cjs/presentation-frontend/Presentation.js +3 -6
  7. package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
  8. package/lib/cjs/presentation-frontend/PresentationManager.js +8 -11
  9. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  10. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +1 -1
  11. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  12. package/lib/cjs/presentation-frontend/StateTracker.js +3 -4
  13. package/lib/cjs/presentation-frontend/StateTracker.js.map +1 -1
  14. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +5 -8
  15. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  16. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +4 -1
  17. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  18. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +4 -1
  19. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  20. package/lib/cjs/presentation-frontend/selection/SelectionManager.js +1 -1
  21. package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
  22. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +2 -2
  23. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +2 -2
  24. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  25. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +1 -1
  26. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  27. package/lib/esm/presentation-frontend/Presentation.d.ts +0 -2
  28. package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
  29. package/lib/esm/presentation-frontend/Presentation.js +3 -6
  30. package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
  31. package/lib/esm/presentation-frontend/PresentationManager.js +8 -11
  32. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  33. package/lib/esm/presentation-frontend/RulesetVariablesManager.js +1 -1
  34. package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  35. package/lib/esm/presentation-frontend/StateTracker.js +3 -4
  36. package/lib/esm/presentation-frontend/StateTracker.js.map +1 -1
  37. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +5 -8
  38. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  39. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +4 -1
  40. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  41. package/lib/esm/presentation-frontend/selection/SelectionHelper.js +4 -1
  42. package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  43. package/lib/esm/presentation-frontend/selection/SelectionManager.js +1 -1
  44. package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
  45. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +2 -2
  46. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +2 -2
  47. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  48. package/package.json +15 -15
@@ -1 +1 @@
1
- {"version":3,"file":"StateTracker.js","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AAoCzD;;;;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AAC;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"]}
1
+ {"version":3,"file":"StateTracker.js","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AAoCzD;;;;;GAKG;AACH,MAAa,YAAY;IAKvB,YAAY,kBAAsC;QAChD,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;QAC9C,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;IACpC,CAAC;IAEO,KAAK,CAAC,4BAA4B,CAAC,SAAiB,EAAE,SAAiB,EAAE,YAAiC;QAChH,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAC3B,OAAO;QACT,MAAM,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;IAC9F,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,MAAwB,EAAE,SAAiB,EAAE,QAAgB;QAC1F,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,cAAc;YACjB,OAAO;QAET,MAAM,YAAY,GAAwB,EAAE,CAAC;QAC7C,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC/B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAC/B,wDAAwD;gBACxD,OAAO;aACR;YACD,IAAA,oBAAK,EAAC,IAAI,6BAA6B,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;gBAClE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,4BAA4B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BAAgB,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"]}
@@ -125,7 +125,6 @@ exports.IModelAppFavoritePropertiesStorage = IModelAppFavoritePropertiesStorage;
125
125
  /** @internal */
126
126
  class OfflineCachingFavoritePropertiesStorage {
127
127
  constructor(props) {
128
- var _a;
129
128
  this._propertiesOfflineCache = new DictionaryWithReservations(iTwinAndIModelIdsKeyComparer);
130
129
  this._propertiesOrderOfflineCache = new DictionaryWithReservations(iTwinAndIModelIdsKeyComparer);
131
130
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -144,7 +143,7 @@ class OfflineCachingFavoritePropertiesStorage {
144
143
  };
145
144
  this._impl = props.impl;
146
145
  // istanbul ignore next
147
- this._connectivityInfo = (_a = props.connectivityInfo) !== null && _a !== void 0 ? _a : new ConnectivityInformationProvider_1.ConnectivityInformationProvider();
146
+ this._connectivityInfo = props.connectivityInfo ?? new ConnectivityInformationProvider_1.ConnectivityInformationProvider();
148
147
  this._connectivityInfo.onInternetConnectivityChanged.addListener(this.onConnectivityStatusChanged);
149
148
  }
150
149
  dispose() {
@@ -210,7 +209,7 @@ class DictionaryWithReservations {
210
209
  constructor(compareKeys) {
211
210
  this._impl = new core_bentley_1.Dictionary(compareKeys);
212
211
  }
213
- get(key) { var _a; return (_a = this._impl.get(key)) === null || _a === void 0 ? void 0 : _a.value; }
212
+ get(key) { return this._impl.get(key)?.value; }
214
213
  forEach(func) {
215
214
  this._impl.forEach((key, entry) => {
216
215
  // istanbul ignore else
@@ -237,9 +236,8 @@ class DictionaryWithReservations {
237
236
  }
238
237
  // istanbul ignore next
239
238
  function iTwinAndIModelIdsKeyComparer(lhs, rhs) {
240
- var _a, _b, _c, _d;
241
- const iTwinIdCompare = (0, core_bentley_1.compareStrings)((_a = lhs[0]) !== null && _a !== void 0 ? _a : "", (_b = rhs[0]) !== null && _b !== void 0 ? _b : "");
242
- return (iTwinIdCompare !== 0) ? iTwinIdCompare : (0, core_bentley_1.compareStrings)((_c = lhs[1]) !== null && _c !== void 0 ? _c : "", (_d = rhs[1]) !== null && _d !== void 0 ? _d : "");
239
+ const iTwinIdCompare = (0, core_bentley_1.compareStrings)(lhs[0] ?? "", rhs[0] ?? "");
240
+ return (iTwinIdCompare !== 0) ? iTwinIdCompare : (0, core_bentley_1.compareStrings)(lhs[1] ?? "", rhs[1] ?? "");
243
241
  }
244
242
  /** @internal */
245
243
  class NoopFavoritePropertiesStorage {
@@ -256,9 +254,8 @@ exports.NoopFavoritePropertiesStorage = NoopFavoritePropertiesStorage;
256
254
  /** @internal */
257
255
  class BrowserLocalFavoritePropertiesStorage {
258
256
  constructor(props) {
259
- var _a;
260
257
  // istanbul ignore next
261
- this._localStorage = (_a = props === null || props === void 0 ? void 0 : props.localStorage) !== null && _a !== void 0 ? _a : window.localStorage;
258
+ this._localStorage = props?.localStorage ?? window.localStorage;
262
259
  }
263
260
  createFavoritesSettingItemKey(iTwinId, imodelId) {
264
261
  return `${exports.IMODELJS_PRESENTATION_SETTING_NAMESPACE}${exports.FAVORITE_PROPERTIES_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;
@@ -1 +1 @@
1
- {"version":3,"file":"FavoritePropertiesStorage.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmI;AACnI,oDAAgE;AAChE,wDAAiD;AACjD,oEAAmF;AACnF,wFAAuH;AAGvH,gBAAgB;AACH,QAAA,uCAAuC,GAAG,uBAAuB,CAAC;AAC/E,gBAAgB;AACH,QAAA,uCAAuC,GAAG,YAAY,CAAC;AACpE,gBAAgB;AACH,QAAA,gCAAgC,GAAG,oBAAoB,CAAC;AACrE,gBAAgB;A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I,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;SAClD,CAAC,CAAC,CAAC;QACJ,OAAO,UAAU,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,UAAyC,EAAE,OAA2B,EAAE,QAAgB;QACvH,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5G,CAAC;CACF;AA3CD,sFA2CC","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 { AccessToken, compareStrings, Dictionary, Guid, IDisposable, isIDisposable, OrderedComparator } from \"@itwin/core-bentley\";\r\nimport { InternetConnectivityStatus } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\r\nimport { ConnectivityInformationProvider, IConnectivityInformationProvider } from \"../ConnectivityInformationProvider\";\r\nimport { FavoritePropertiesOrderInfo, PropertyFullName } from \"./FavoritePropertiesManager\";\r\n\r\n/** @internal */\r\nexport const IMODELJS_PRESENTATION_SETTING_NAMESPACE = \"imodeljs.presentation\";\r\n/** @internal */\r\nexport const DEPRECATED_PROPERTIES_SETTING_NAMESPACE = \"Properties\";\r\n/** @internal */\r\nexport const FAVORITE_PROPERTIES_SETTING_NAME = \"FavoriteProperties\";\r\n/** @internal */\r\nexport const FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME = \"FavoritePropertiesOrderInfo\";\r\n\r\n/**\r\n * Stores user preferences for favorite properties.\r\n * @public\r\n */\r\nexport interface IFavoritePropertiesStorage {\r\n /** Load Favorite properties from user-specific settings.\r\n * @param iTwinId ITwin Id, if the settings is specific to a iTwin, otherwise undefined.\r\n * @param imodelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\r\n */\r\n loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined>;\r\n /** Saves Favorite properties to user-specific settings.\r\n * @param properties Favorite properties to save.\r\n * @param iTwinId iTwin Id, if the settings is specific to a iTwin, otherwise undefined.\r\n * @param iModelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\r\n */\r\n saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void>;\r\n /** Load array of FavoritePropertiesOrderInfo from user-specific settings.\r\n * Setting is specific to an iModel.\r\n * @param iTwinId iTwin Id.\r\n * @param imodelId iModel Id.\r\n */\r\n loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined>;\r\n /** Saves FavoritePropertiesOrderInfo array to user-specific settings.\r\n * Setting is specific to an iModel.\r\n * @param orderInfo Array of FavoritePropertiesOrderInfo to save.\r\n * @param iTwinId iTwin Id.\r\n * @param imodelId iModel Id.\r\n */\r\n savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void>;\r\n}\r\n\r\n/**\r\n * Available implementations of [[IFavoritePropertiesStorage]].\r\n * @public\r\n */\r\nexport enum DefaultFavoritePropertiesStorageTypes {\r\n /** A no-op storage that doesn't store or return anything. Used for cases when favorite properties aren't used by the application. */\r\n Noop,\r\n /** A storage that stores favorite properties information in a browser local storage. */\r\n BrowserLocalStorage,\r\n /** A storage that stores favorite properties in a user preferences storage (see [[IModelApp.userPreferences]]). */\r\n UserPreferencesStorage,\r\n}\r\n\r\n/**\r\n * A factory method to create one of the available [[IFavoritePropertiesStorage]] implementations.\r\n * @public\r\n */\r\nexport function createFavoritePropertiesStorage(type: DefaultFavoritePropertiesStorageTypes): IFavoritePropertiesStorage {\r\n switch (type) {\r\n case DefaultFavoritePropertiesStorageTypes.Noop: return new NoopFavoritePropertiesStorage();\r\n case DefaultFavoritePropertiesStorageTypes.BrowserLocalStorage: return new BrowserLocalFavoritePropertiesStorage();\r\n case DefaultFavoritePropertiesStorageTypes.UserPreferencesStorage: return new OfflineCachingFavoritePropertiesStorage({ impl: new IModelAppFavoritePropertiesStorage() });\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class IModelAppFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n\r\n private async ensureIsSignedIn(): Promise<{ accessToken: AccessToken }> {\r\n const accessToken = IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : \"\";\r\n if (accessToken)\r\n return { accessToken };\r\n throw new PresentationError(PresentationStatus.Error, \"Current user is not authorized to use the settings service\");\r\n }\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n let setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n });\r\n\r\n if (setting !== undefined)\r\n return new Set<PropertyFullName>(setting);\r\n\r\n // try to check the old namespace\r\n setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: DEPRECATED_PROPERTIES_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n });\r\n\r\n if (setting !== undefined && setting.hasOwnProperty(\"nestedContentInfos\") && setting.hasOwnProperty(\"propertyInfos\") && setting.hasOwnProperty(\"baseFieldInfos\"))\r\n return new Set<PropertyFullName>([...setting.nestedContentInfos, ...setting.propertyInfos, ...setting.baseFieldInfos]);\r\n\r\n return undefined;\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void> {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n await IModelApp.userPreferences.save({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n content: Array.from(properties),\r\n });\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n const setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\r\n });\r\n return setting as FavoritePropertiesOrderInfo[];\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n await IModelApp.userPreferences.save({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\r\n content: orderInfos,\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface OfflineCachingFavoritePropertiesStorageProps {\r\n impl: IFavoritePropertiesStorage;\r\n connectivityInfo?: IConnectivityInformationProvider;\r\n}\r\n/** @internal */\r\nexport class OfflineCachingFavoritePropertiesStorage implements IFavoritePropertiesStorage, IDisposable {\r\n\r\n private _connectivityInfo: IConnectivityInformationProvider;\r\n private _impl: IFavoritePropertiesStorage;\r\n private _propertiesOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, Set<PropertyFullName>>(iTwinAndIModelIdsKeyComparer);\r\n private _propertiesOrderOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, FavoritePropertiesOrderInfo[]>(iTwinAndIModelIdsKeyComparer);\r\n\r\n public constructor(props: OfflineCachingFavoritePropertiesStorageProps) {\r\n this._impl = props.impl;\r\n // istanbul ignore next\r\n this._connectivityInfo = props.connectivityInfo ?? new ConnectivityInformationProvider();\r\n this._connectivityInfo.onInternetConnectivityChanged.addListener(this.onConnectivityStatusChanged);\r\n }\r\n\r\n public dispose() {\r\n if (isIDisposable(this._connectivityInfo))\r\n this._connectivityInfo.dispose();\r\n }\r\n\r\n public get impl() { return this._impl; }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onConnectivityStatusChanged = (args: { status: InternetConnectivityStatus }) => {\r\n // istanbul ignore else\r\n if (args.status === InternetConnectivityStatus.Online) {\r\n // note: we're copying the cached values to temp arrays because `saveProperties` and `savePropertiesOrder` both\r\n // attempt to modify cache dictionaries\r\n\r\n const propertiesCache = new Array<{ properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string }>();\r\n this._propertiesOfflineCache.forEach((key, value) => propertiesCache.push({ properties: value, iTwinId: key[0], imodelId: key[1] }));\r\n propertiesCache.forEach(async (cached) => this.saveProperties(cached.properties, cached.iTwinId, cached.imodelId));\r\n\r\n const ordersCache = new Array<{ order: FavoritePropertiesOrderInfo[], iTwinId?: string, imodelId: string }>();\r\n this._propertiesOrderOfflineCache.forEach((key, value) => ordersCache.push({ order: value, iTwinId: key[0], imodelId: key[1]! }));\r\n ordersCache.forEach(async (cached) => this.savePropertiesOrder(cached.order, cached.iTwinId, cached.imodelId));\r\n }\r\n };\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string) {\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\r\n try {\r\n return await this._impl.loadProperties(iTwinId, imodelId);\r\n } catch {\r\n // return from offline cache if the above fails\r\n }\r\n }\r\n return this._propertiesOfflineCache.get([iTwinId, imodelId]);\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\r\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\r\n this._propertiesOfflineCache.set(key, properties);\r\n return;\r\n }\r\n const reservationId = this._propertiesOfflineCache.reserve(key);\r\n try {\r\n await this._impl.saveProperties(properties, iTwinId, imodelId);\r\n this._propertiesOfflineCache.reservedDelete(key, reservationId);\r\n } catch {\r\n this._propertiesOfflineCache.reservedSet(key, properties, reservationId);\r\n }\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string) {\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\r\n try {\r\n return await this._impl.loadPropertiesOrder(iTwinId, imodelId);\r\n } catch {\r\n // return from offline cache if the above fails\r\n }\r\n }\r\n return this._propertiesOrderOfflineCache.get([iTwinId, imodelId]);\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\r\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\r\n this._propertiesOrderOfflineCache.set(key, orderInfos);\r\n return;\r\n }\r\n const reservationId = this._propertiesOrderOfflineCache.reserve(key);\r\n try {\r\n await this._impl.savePropertiesOrder(orderInfos, iTwinId, imodelId);\r\n this._propertiesOrderOfflineCache.reservedDelete(key, reservationId);\r\n } catch {\r\n this._propertiesOrderOfflineCache.reservedSet(key, orderInfos, reservationId);\r\n }\r\n }\r\n\r\n}\r\n\r\nclass DictionaryWithReservations<TKey, TValue> {\r\n private _impl: Dictionary<TKey, { value?: TValue, lastReservationId?: string }>;\r\n public constructor(compareKeys: OrderedComparator<TKey>) {\r\n this._impl = new Dictionary(compareKeys);\r\n }\r\n public get(key: TKey) { return this._impl.get(key)?.value; }\r\n public forEach(func: (key: TKey, value: TValue) => void): void {\r\n this._impl.forEach((key, entry) => {\r\n // istanbul ignore else\r\n if (entry.value)\r\n func(key, entry.value);\r\n });\r\n }\r\n public reserve(key: TKey) {\r\n const reservationId = Guid.createValue();\r\n this._impl.set(key, { lastReservationId: reservationId });\r\n return reservationId;\r\n }\r\n public set(key: TKey, value: TValue) { return this._impl.set(key, { value }); }\r\n public reservedSet(key: TKey, value: TValue, reservationId: string) {\r\n const entry = this._impl.get(key);\r\n if (entry && entry.lastReservationId === reservationId)\r\n this._impl.set(key, { value });\r\n }\r\n public reservedDelete(key: TKey, reservationId: string) {\r\n const entry = this._impl.get(key);\r\n if (entry && entry.lastReservationId === reservationId)\r\n this._impl.delete(key);\r\n }\r\n}\r\ntype ITwinAndIModelIdsKey = [string | undefined, string | undefined];\r\n\r\n// istanbul ignore next\r\nfunction iTwinAndIModelIdsKeyComparer(lhs: ITwinAndIModelIdsKey, rhs: ITwinAndIModelIdsKey) {\r\n const iTwinIdCompare = compareStrings(lhs[0] ?? \"\", rhs[0] ?? \"\");\r\n return (iTwinIdCompare !== 0) ? iTwinIdCompare : compareStrings(lhs[1] ?? \"\", rhs[1] ?? \"\");\r\n}\r\n\r\n/** @internal */\r\nexport class NoopFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n // istanbul ignore next\r\n public async loadProperties(_iTwinId?: string, _imodelId?: string): Promise<Set<PropertyFullName> | undefined> { return undefined; }\r\n // istanbul ignore next\r\n public async saveProperties(_properties: Set<PropertyFullName>, _iTwinId?: string, _imodelId?: string) { }\r\n // istanbul ignore next\r\n public async loadPropertiesOrder(_iTwinId: string | undefined, _imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> { return undefined; }\r\n // istanbul ignore next\r\n public async savePropertiesOrder(_orderInfos: FavoritePropertiesOrderInfo[], _iTwinId: string | undefined, _imodelId: string): Promise<void> { }\r\n}\r\n\r\n/** @internal */\r\nexport class BrowserLocalFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n private _localStorage: Storage;\r\n\r\n public constructor(props?: { localStorage?: Storage }) {\r\n // istanbul ignore next\r\n this._localStorage = props?.localStorage ?? window.localStorage;\r\n }\r\n\r\n public createFavoritesSettingItemKey(iTwinId?: string, imodelId?: string): string {\r\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\r\n }\r\n public createOrderSettingItemKey(iTwinId?: string, imodelId?: string): string {\r\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\r\n }\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\r\n const value = this._localStorage.getItem(this.createFavoritesSettingItemKey(iTwinId, imodelId));\r\n if (!value)\r\n return undefined;\r\n\r\n const properties: PropertyFullName[] = JSON.parse(value);\r\n return new Set(properties);\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\r\n this._localStorage.setItem(this.createFavoritesSettingItemKey(iTwinId, imodelId), JSON.stringify([...properties]));\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\r\n const value = this._localStorage.getItem(this.createOrderSettingItemKey(iTwinId, imodelId));\r\n if (!value)\r\n return undefined;\r\n\r\n const orderInfos: FavoritePropertiesOrderInfo[] = JSON.parse(value).map((json: any) => ({\r\n ...json,\r\n orderedTimestamp: new Date(json.orderedTimestamp),\r\n }));\r\n return orderInfos;\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void> {\r\n this._localStorage.setItem(this.createOrderSettingItemKey(iTwinId, imodelId), JSON.stringify(orderInfos));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"FavoritePropertiesStorage.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/favorite-properties/FavoritePropertiesStorage.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmI;AACnI,oDAAgE;AAChE,wDAAiD;AACjD,oEAAmF;AACnF,wFAAuH;AAGvH,gBAAgB;AACH,QAAA,uCAAuC,GAAG,uBAAuB,CAAC;AAC/E,gBAAgB;AACH,QAAA,uCAAuC,GAAG,YAAY,CAAC;AACpE,gBAAgB;AACH,QAAA,gCAAgC,GAAG,oBAAoB,CAAC;AACrE,gBAAgB;AACH,QAAA,2CAA2C,GAAG,6BAA6B,CAAC;AAiCzF;;;GAGG;AACH,IAAY,qCAOX;AAPD,WAAY,qCAAqC;IAC/C,qIAAqI;IACrI,iGAAI,CAAA;IACJ,wFAAwF;IACxF,+HAAmB,CAAA;IACnB,mHAAmH;IACnH,qIAAsB,CAAA;AACxB,CAAC,EAPW,qCAAqC,GAArC,6CAAqC,KAArC,6CAAqC,QAOhD;AAED;;;GAGG;AACH,SAAgB,+BAA+B,CAAC,IAA2C;IACzF,QAAQ,IAAI,EAAE;QACZ,KAAK,qCAAqC,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,6BAA6B,EAAE,CAAC;QAC5F,KAAK,qCAAqC,CAAC,mBAAmB,CAAC,CAAC,OAAO,IAAI,qCAAqC,EAAE,CAAC;QACnH,KAAK,qCAAqC,CAAC,sBAAsB,CAAC,CAAC,OAAO,IAAI,uCAAuC,CAAC,EAAE,IAAI,EAAE,IAAI,kCAAkC,EAAE,EAAE,CAAC,CAAC;KAC3K;AACH,CAAC;AAND,0EAM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A6B,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACrH,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,OAA2B,EAAE,QAAgB;QAC5E,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC5F,IAAI,CAAC,KAAK;YACR,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAkC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YACtF,GAAG,IAAI;YACP,gBAAgB,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC;SAClD,CAAC,CAAC,CAAC;QACJ,OAAO,UAAU,CAAC;IACpB,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAAC,UAAyC,EAAE,OAA2B,EAAE,QAAgB;QACvH,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC5G,CAAC;CACF;AA3CD,sFA2CC","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 { AccessToken, compareStrings, Dictionary, Guid, IDisposable, isIDisposable, OrderedComparator } from \"@itwin/core-bentley\";\r\nimport { InternetConnectivityStatus } from \"@itwin/core-common\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\r\nimport { ConnectivityInformationProvider, IConnectivityInformationProvider } from \"../ConnectivityInformationProvider\";\r\nimport { FavoritePropertiesOrderInfo, PropertyFullName } from \"./FavoritePropertiesManager\";\r\n\r\n/** @internal */\r\nexport const IMODELJS_PRESENTATION_SETTING_NAMESPACE = \"imodeljs.presentation\";\r\n/** @internal */\r\nexport const DEPRECATED_PROPERTIES_SETTING_NAMESPACE = \"Properties\";\r\n/** @internal */\r\nexport const FAVORITE_PROPERTIES_SETTING_NAME = \"FavoriteProperties\";\r\n/** @internal */\r\nexport const FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME = \"FavoritePropertiesOrderInfo\";\r\n\r\n/**\r\n * Stores user preferences for favorite properties.\r\n * @public\r\n */\r\nexport interface IFavoritePropertiesStorage {\r\n /** Load Favorite properties from user-specific settings.\r\n * @param iTwinId ITwin Id, if the settings is specific to a iTwin, otherwise undefined.\r\n * @param imodelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\r\n */\r\n loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined>;\r\n /** Saves Favorite properties to user-specific settings.\r\n * @param properties Favorite properties to save.\r\n * @param iTwinId iTwin Id, if the settings is specific to a iTwin, otherwise undefined.\r\n * @param iModelId iModel Id, if the setting is specific to an iModel, otherwise undefined. The iTwinId must be specified if iModelId is specified.\r\n */\r\n saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void>;\r\n /** Load array of FavoritePropertiesOrderInfo from user-specific settings.\r\n * Setting is specific to an iModel.\r\n * @param iTwinId iTwin Id.\r\n * @param imodelId iModel Id.\r\n */\r\n loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined>;\r\n /** Saves FavoritePropertiesOrderInfo array to user-specific settings.\r\n * Setting is specific to an iModel.\r\n * @param orderInfo Array of FavoritePropertiesOrderInfo to save.\r\n * @param iTwinId iTwin Id.\r\n * @param imodelId iModel Id.\r\n */\r\n savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void>;\r\n}\r\n\r\n/**\r\n * Available implementations of [[IFavoritePropertiesStorage]].\r\n * @public\r\n */\r\nexport enum DefaultFavoritePropertiesStorageTypes {\r\n /** A no-op storage that doesn't store or return anything. Used for cases when favorite properties aren't used by the application. */\r\n Noop,\r\n /** A storage that stores favorite properties information in a browser local storage. */\r\n BrowserLocalStorage,\r\n /** A storage that stores favorite properties in a user preferences storage (see [[IModelApp.userPreferences]]). */\r\n UserPreferencesStorage,\r\n}\r\n\r\n/**\r\n * A factory method to create one of the available [[IFavoritePropertiesStorage]] implementations.\r\n * @public\r\n */\r\nexport function createFavoritePropertiesStorage(type: DefaultFavoritePropertiesStorageTypes): IFavoritePropertiesStorage {\r\n switch (type) {\r\n case DefaultFavoritePropertiesStorageTypes.Noop: return new NoopFavoritePropertiesStorage();\r\n case DefaultFavoritePropertiesStorageTypes.BrowserLocalStorage: return new BrowserLocalFavoritePropertiesStorage();\r\n case DefaultFavoritePropertiesStorageTypes.UserPreferencesStorage: return new OfflineCachingFavoritePropertiesStorage({ impl: new IModelAppFavoritePropertiesStorage() });\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class IModelAppFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n\r\n private async ensureIsSignedIn(): Promise<{ accessToken: AccessToken }> {\r\n const accessToken = IModelApp.authorizationClient ? await IModelApp.authorizationClient.getAccessToken() : \"\";\r\n if (accessToken)\r\n return { accessToken };\r\n throw new PresentationError(PresentationStatus.Error, \"Current user is not authorized to use the settings service\");\r\n }\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n let setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n });\r\n\r\n if (setting !== undefined)\r\n return new Set<PropertyFullName>(setting);\r\n\r\n // try to check the old namespace\r\n setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: DEPRECATED_PROPERTIES_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n });\r\n\r\n if (setting !== undefined && setting.hasOwnProperty(\"nestedContentInfos\") && setting.hasOwnProperty(\"propertyInfos\") && setting.hasOwnProperty(\"baseFieldInfos\"))\r\n return new Set<PropertyFullName>([...setting.nestedContentInfos, ...setting.propertyInfos, ...setting.baseFieldInfos]);\r\n\r\n return undefined;\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string): Promise<void> {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n await IModelApp.userPreferences.save({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_SETTING_NAME,\r\n content: Array.from(properties),\r\n });\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n const setting = await IModelApp.userPreferences.get({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\r\n });\r\n return setting as FavoritePropertiesOrderInfo[];\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\r\n if (!IModelApp.userPreferences)\r\n throw new PresentationError(PresentationStatus.Error, \"User preferences service is not set up\");\r\n\r\n const { accessToken } = await this.ensureIsSignedIn();\r\n await IModelApp.userPreferences.save({\r\n accessToken,\r\n iTwinId,\r\n iModelId: imodelId,\r\n namespace: IMODELJS_PRESENTATION_SETTING_NAMESPACE,\r\n key: FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME,\r\n content: orderInfos,\r\n });\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface OfflineCachingFavoritePropertiesStorageProps {\r\n impl: IFavoritePropertiesStorage;\r\n connectivityInfo?: IConnectivityInformationProvider;\r\n}\r\n/** @internal */\r\nexport class OfflineCachingFavoritePropertiesStorage implements IFavoritePropertiesStorage, IDisposable {\r\n\r\n private _connectivityInfo: IConnectivityInformationProvider;\r\n private _impl: IFavoritePropertiesStorage;\r\n private _propertiesOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, Set<PropertyFullName>>(iTwinAndIModelIdsKeyComparer);\r\n private _propertiesOrderOfflineCache = new DictionaryWithReservations<ITwinAndIModelIdsKey, FavoritePropertiesOrderInfo[]>(iTwinAndIModelIdsKeyComparer);\r\n\r\n public constructor(props: OfflineCachingFavoritePropertiesStorageProps) {\r\n this._impl = props.impl;\r\n // istanbul ignore next\r\n this._connectivityInfo = props.connectivityInfo ?? new ConnectivityInformationProvider();\r\n this._connectivityInfo.onInternetConnectivityChanged.addListener(this.onConnectivityStatusChanged);\r\n }\r\n\r\n public dispose() {\r\n if (isIDisposable(this._connectivityInfo))\r\n this._connectivityInfo.dispose();\r\n }\r\n\r\n public get impl() { return this._impl; }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onConnectivityStatusChanged = (args: { status: InternetConnectivityStatus }) => {\r\n // istanbul ignore else\r\n if (args.status === InternetConnectivityStatus.Online) {\r\n // note: we're copying the cached values to temp arrays because `saveProperties` and `savePropertiesOrder` both\r\n // attempt to modify cache dictionaries\r\n\r\n const propertiesCache = new Array<{ properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string }>();\r\n this._propertiesOfflineCache.forEach((key, value) => propertiesCache.push({ properties: value, iTwinId: key[0], imodelId: key[1] }));\r\n propertiesCache.forEach(async (cached) => this.saveProperties(cached.properties, cached.iTwinId, cached.imodelId));\r\n\r\n const ordersCache = new Array<{ order: FavoritePropertiesOrderInfo[], iTwinId?: string, imodelId: string }>();\r\n this._propertiesOrderOfflineCache.forEach((key, value) => ordersCache.push({ order: value, iTwinId: key[0], imodelId: key[1]! }));\r\n ordersCache.forEach(async (cached) => this.savePropertiesOrder(cached.order, cached.iTwinId, cached.imodelId));\r\n }\r\n };\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string) {\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\r\n try {\r\n return await this._impl.loadProperties(iTwinId, imodelId);\r\n } catch {\r\n // return from offline cache if the above fails\r\n }\r\n }\r\n return this._propertiesOfflineCache.get([iTwinId, imodelId]);\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\r\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\r\n this._propertiesOfflineCache.set(key, properties);\r\n return;\r\n }\r\n const reservationId = this._propertiesOfflineCache.reserve(key);\r\n try {\r\n await this._impl.saveProperties(properties, iTwinId, imodelId);\r\n this._propertiesOfflineCache.reservedDelete(key, reservationId);\r\n } catch {\r\n this._propertiesOfflineCache.reservedSet(key, properties, reservationId);\r\n }\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string) {\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Online) {\r\n try {\r\n return await this._impl.loadPropertiesOrder(iTwinId, imodelId);\r\n } catch {\r\n // return from offline cache if the above fails\r\n }\r\n }\r\n return this._propertiesOrderOfflineCache.get([iTwinId, imodelId]);\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string) {\r\n const key: ITwinAndIModelIdsKey = [iTwinId, imodelId];\r\n if (this._connectivityInfo.status === InternetConnectivityStatus.Offline) {\r\n this._propertiesOrderOfflineCache.set(key, orderInfos);\r\n return;\r\n }\r\n const reservationId = this._propertiesOrderOfflineCache.reserve(key);\r\n try {\r\n await this._impl.savePropertiesOrder(orderInfos, iTwinId, imodelId);\r\n this._propertiesOrderOfflineCache.reservedDelete(key, reservationId);\r\n } catch {\r\n this._propertiesOrderOfflineCache.reservedSet(key, orderInfos, reservationId);\r\n }\r\n }\r\n\r\n}\r\n\r\nclass DictionaryWithReservations<TKey, TValue> {\r\n private _impl: Dictionary<TKey, { value?: TValue, lastReservationId?: string }>;\r\n public constructor(compareKeys: OrderedComparator<TKey>) {\r\n this._impl = new Dictionary(compareKeys);\r\n }\r\n public get(key: TKey) { return this._impl.get(key)?.value; }\r\n public forEach(func: (key: TKey, value: TValue) => void): void {\r\n this._impl.forEach((key, entry) => {\r\n // istanbul ignore else\r\n if (entry.value)\r\n func(key, entry.value);\r\n });\r\n }\r\n public reserve(key: TKey) {\r\n const reservationId = Guid.createValue();\r\n this._impl.set(key, { lastReservationId: reservationId });\r\n return reservationId;\r\n }\r\n public set(key: TKey, value: TValue) { return this._impl.set(key, { value }); }\r\n public reservedSet(key: TKey, value: TValue, reservationId: string) {\r\n const entry = this._impl.get(key);\r\n if (entry && entry.lastReservationId === reservationId)\r\n this._impl.set(key, { value });\r\n }\r\n public reservedDelete(key: TKey, reservationId: string) {\r\n const entry = this._impl.get(key);\r\n if (entry && entry.lastReservationId === reservationId)\r\n this._impl.delete(key);\r\n }\r\n}\r\ntype ITwinAndIModelIdsKey = [string | undefined, string | undefined];\r\n\r\n// istanbul ignore next\r\nfunction iTwinAndIModelIdsKeyComparer(lhs: ITwinAndIModelIdsKey, rhs: ITwinAndIModelIdsKey) {\r\n const iTwinIdCompare = compareStrings(lhs[0] ?? \"\", rhs[0] ?? \"\");\r\n return (iTwinIdCompare !== 0) ? iTwinIdCompare : compareStrings(lhs[1] ?? \"\", rhs[1] ?? \"\");\r\n}\r\n\r\n/** @internal */\r\nexport class NoopFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n // istanbul ignore next\r\n public async loadProperties(_iTwinId?: string, _imodelId?: string): Promise<Set<PropertyFullName> | undefined> { return undefined; }\r\n // istanbul ignore next\r\n public async saveProperties(_properties: Set<PropertyFullName>, _iTwinId?: string, _imodelId?: string) { }\r\n // istanbul ignore next\r\n public async loadPropertiesOrder(_iTwinId: string | undefined, _imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> { return undefined; }\r\n // istanbul ignore next\r\n public async savePropertiesOrder(_orderInfos: FavoritePropertiesOrderInfo[], _iTwinId: string | undefined, _imodelId: string): Promise<void> { }\r\n}\r\n\r\n/** @internal */\r\nexport class BrowserLocalFavoritePropertiesStorage implements IFavoritePropertiesStorage {\r\n private _localStorage: Storage;\r\n\r\n public constructor(props?: { localStorage?: Storage }) {\r\n // istanbul ignore next\r\n this._localStorage = props?.localStorage ?? window.localStorage;\r\n }\r\n\r\n public createFavoritesSettingItemKey(iTwinId?: string, imodelId?: string): string {\r\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\r\n }\r\n public createOrderSettingItemKey(iTwinId?: string, imodelId?: string): string {\r\n return `${IMODELJS_PRESENTATION_SETTING_NAMESPACE}${FAVORITE_PROPERTIES_ORDER_INFO_SETTING_NAME}?iTwinId=${iTwinId}&imodelId=${imodelId}`;\r\n }\r\n\r\n public async loadProperties(iTwinId?: string, imodelId?: string): Promise<Set<PropertyFullName> | undefined> {\r\n const value = this._localStorage.getItem(this.createFavoritesSettingItemKey(iTwinId, imodelId));\r\n if (!value)\r\n return undefined;\r\n\r\n const properties: PropertyFullName[] = JSON.parse(value);\r\n return new Set(properties);\r\n }\r\n\r\n public async saveProperties(properties: Set<PropertyFullName>, iTwinId?: string, imodelId?: string) {\r\n this._localStorage.setItem(this.createFavoritesSettingItemKey(iTwinId, imodelId), JSON.stringify([...properties]));\r\n }\r\n\r\n public async loadPropertiesOrder(iTwinId: string | undefined, imodelId: string): Promise<FavoritePropertiesOrderInfo[] | undefined> {\r\n const value = this._localStorage.getItem(this.createOrderSettingItemKey(iTwinId, imodelId));\r\n if (!value)\r\n return undefined;\r\n\r\n const orderInfos: FavoritePropertiesOrderInfo[] = JSON.parse(value).map((json: any) => ({\r\n ...json,\r\n orderedTimestamp: new Date(json.orderedTimestamp),\r\n }));\r\n return orderInfos;\r\n }\r\n\r\n public async savePropertiesOrder(orderInfos: FavoritePropertiesOrderInfo[], iTwinId: string | undefined, imodelId: string): Promise<void> {\r\n this._localStorage.setItem(this.createOrderSettingItemKey(iTwinId, imodelId), JSON.stringify(orderInfos));\r\n }\r\n}\r\n"]}
@@ -2,7 +2,10 @@
2
2
  * @module UnifiedSelection
3
3
  */
4
4
  import { Key, Keys } from "@itwin/presentation-common";
5
- /** @internal */
5
+ /**
6
+ * Helper class for working with selection.
7
+ * @public
8
+ */
6
9
  export declare class SelectionHelper {
7
10
  private constructor();
8
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHelper.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE,gBAAgB;AAChB,qBAAa,eAAe;IAG1B,OAAO;IAEP;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;CAe/D"}
1
+ {"version":3,"file":"SelectionHelper.d.ts","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,IAAI,EAAW,MAAM,4BAA4B,CAAC;AAEhE;;;GAGG;AACH,qBAAa,eAAe;IAG1B,OAAO;IAEP;;;;OAIG;WACW,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,GAAG,EAAE;CAe/D"}
@@ -9,7 +9,10 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.SelectionHelper = void 0;
11
11
  const presentation_common_1 = require("@itwin/presentation-common");
12
- /** @internal */
12
+ /**
13
+ * Helper class for working with selection.
14
+ * @public
15
+ */
13
16
  class SelectionHelper {
14
17
  // istanbul ignore next
15
18
  constructor() { }
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oEAAgE;AAEhE,gBAAgB;AAChB,MAAa,eAAe;IAE1B,uBAAuB;IACvB,gBAAwB,CAAC;IAEzB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,yBAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;gBACtB,IAAI,6BAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;;oBAEjC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF;AAzBD,0CAyBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\r\n\r\n/** @internal */\r\nexport class SelectionHelper {\r\n\r\n // istanbul ignore next\r\n private constructor() { }\r\n\r\n /**\r\n * Re-map the given keyset for selection. This means all instance node keys get converted\r\n * to instance keys, because in that case we want to select instances instead of nodes. All\r\n * other types of keys ar left as is.\r\n */\r\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\r\n const result = new Array<Key>();\r\n keys.forEach((key: Key) => {\r\n if (Key.isNodeKey(key)) {\r\n if (NodeKey.isInstancesNodeKey(key))\r\n result.push(...key.instanceKeys);\r\n else\r\n result.push(key);\r\n } else {\r\n result.push(key);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionHelper.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionHelper.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oEAAgE;AAEhE;;;GAGG;AACH,MAAa,eAAe;IAE1B,uBAAuB;IACvB,gBAAwB,CAAC;IAEzB;;;;OAIG;IACI,MAAM,CAAC,mBAAmB,CAAC,IAAoB;QACpD,MAAM,MAAM,GAAG,IAAI,KAAK,EAAO,CAAC;QAChC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;YACxB,IAAI,yBAAG,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE;gBACtB,IAAI,6BAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC;oBACjC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;;oBAEjC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACpB;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;QACH,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CAEF;AAzBD,0CAyBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Key, Keys, NodeKey } from \"@itwin/presentation-common\";\r\n\r\n/**\r\n * Helper class for working with selection.\r\n * @public\r\n */\r\nexport class SelectionHelper {\r\n\r\n // istanbul ignore next\r\n private constructor() { }\r\n\r\n /**\r\n * Re-map the given keyset for selection. This means all instance node keys get converted\r\n * to instance keys, because in that case we want to select instances instead of nodes. All\r\n * other types of keys ar left as is.\r\n */\r\n public static getKeysForSelection(keys: Readonly<Keys>): Key[] {\r\n const result = new Array<Key>();\r\n keys.forEach((key: Key) => {\r\n if (Key.isNodeKey(key)) {\r\n if (NodeKey.isInstancesNodeKey(key))\r\n result.push(...key.instanceKeys);\r\n else\r\n result.push(key);\r\n } else {\r\n result.push(key);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n}\r\n"]}
@@ -47,7 +47,7 @@ class SelectionManager {
47
47
  }
48
48
  /** @internal */
49
49
  // istanbul ignore next
50
- getToolSelectionSyncHandler(imodel) { var _a; return (_a = this._imodelToolSelectionSyncHandlers.get(imodel)) === null || _a === void 0 ? void 0 : _a.handler; }
50
+ getToolSelectionSyncHandler(imodel) { return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler; }
51
51
  /**
52
52
  * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).
53
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionManager.js","sourceRoot":"","sources":["../../../../src/presentation-front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,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChG,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACnE,CAAC;IACM,KAAK,CAAC,MAAM,CAAC,YAAqB,EAAE,aAAsB,EAAE,KAAa;QAC9E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChG,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACxE,CAAC;IACM,KAAK,CAAC,OAAO,CAAC,YAAqB,EAAE,aAAsB,EAAE,KAAa;QAC/E,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAChG,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Id64, Id64Arg, Id64Array, IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection, SelectionSetEvent, SelectionSetEventType } from \"@itwin/core-frontend\";\r\nimport { AsyncTasksTracker, Keys, KeySet, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\nimport { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\nimport { SelectionChangeEvent, SelectionChangeEventArgs, SelectionChangeType } from \"./SelectionChangeEvent\";\r\nimport { createSelectionScopeProps, SelectionScopesManager } from \"./SelectionScopesManager\";\r\n\r\n/**\r\n * Properties for creating [[SelectionManager]].\r\n * @public\r\n */\r\nexport interface SelectionManagerProps {\r\n /** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n scopes: SelectionScopesManager;\r\n}\r\n\r\n/**\r\n * The selection manager which stores the overall selection.\r\n * @public\r\n */\r\nexport class SelectionManager implements ISelectionProvider {\r\n private _selectionContainerMap = new Map<IModelConnection, SelectionContainer>();\r\n private _imodelToolSelectionSyncHandlers = new Map<IModelConnection, { requestorsCount: number, handler: ToolSelectionSyncHandler }>();\r\n private _hiliteSetProviders = new Map<IModelConnection, HiliteSetProvider>();\r\n\r\n /** An event which gets broadcasted on selection changes */\r\n public readonly selectionChange: SelectionChangeEvent;\r\n\r\n /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n public readonly scopes: SelectionScopesManager;\r\n\r\n /**\r\n * Creates an instance of SelectionManager.\r\n */\r\n constructor(props: SelectionManagerProps) {\r\n this.selectionChange = new SelectionChangeEvent();\r\n this.scopes = props.scopes;\r\n IModelConnection.onClose.addListener((imodel: IModelConnection) => {\r\n this.onConnectionClose(imodel);\r\n });\r\n }\r\n\r\n private onConnectionClose(imodel: IModelConnection): void {\r\n this.clearSelection(\"Connection Close Event\", imodel);\r\n this._selectionContainerMap.delete(imodel);\r\n this._hiliteSetProviders.delete(imodel);\r\n }\r\n\r\n private getContainer(imodel: IModelConnection): SelectionContainer {\r\n let selectionContainer = this._selectionContainerMap.get(imodel);\r\n if (!selectionContainer) {\r\n selectionContainer = new SelectionContainer();\r\n this._selectionContainerMap.set(imodel, selectionContainer);\r\n }\r\n return selectionContainer;\r\n }\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getToolSelectionSyncHandler(imodel: IModelConnection) { return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler; }\r\n\r\n /**\r\n * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).\r\n */\r\n public setSyncWithIModelToolSelection(imodel: IModelConnection, sync = true) {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (sync) {\r\n if (!registration || registration.requestorsCount === 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { requestorsCount: 1, handler: new ToolSelectionSyncHandler(imodel, this) });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount: registration.requestorsCount + 1 });\r\n }\r\n } else {\r\n if (registration && registration.requestorsCount > 0) {\r\n const requestorsCount = registration.requestorsCount - 1;\r\n if (requestorsCount > 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.delete(imodel);\r\n registration.handler.dispose();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Temporarily suspends tool selection synchronization until the returned `IDisposable`\r\n * is disposed.\r\n */\r\n public suspendIModelToolSelectionSync(imodel: IModelConnection): IDisposable {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (!registration)\r\n return { dispose: () => { } };\r\n\r\n const wasSuspended = registration.handler.isSuspended;\r\n registration.handler.isSuspended = true;\r\n return { dispose: () => (registration.handler.isSuspended = wasSuspended) };\r\n }\r\n\r\n /** Get the selection levels currently stored in this manager for the specified imodel */\r\n public getSelectionLevels(imodel: IModelConnection): number[] {\r\n return this.getContainer(imodel).getSelectionLevels();\r\n }\r\n\r\n /** Get the selection currently stored in this manager */\r\n public getSelection(imodel: IModelConnection, level: number = 0): Readonly<KeySet> {\r\n return this.getContainer(imodel).getSelection(level);\r\n }\r\n\r\n private handleEvent(evt: SelectionChangeEventArgs): void {\r\n const container = this.getContainer(evt.imodel);\r\n const selectedItemsSet = container.getSelection(evt.level);\r\n const guidBefore = selectedItemsSet.guid;\r\n switch (evt.changeType) {\r\n case SelectionChangeType.Add:\r\n selectedItemsSet.add(evt.keys);\r\n break;\r\n case SelectionChangeType.Remove:\r\n selectedItemsSet.delete(evt.keys);\r\n break;\r\n case SelectionChangeType.Replace:\r\n if (selectedItemsSet.size !== evt.keys.size || !selectedItemsSet.hasAll(evt.keys)) {\r\n // note: the above check is only needed to avoid changing\r\n // guid of the keyset if we're replacing keyset with the same keys\r\n selectedItemsSet.clear().add(evt.keys);\r\n }\r\n break;\r\n case SelectionChangeType.Clear:\r\n selectedItemsSet.clear();\r\n break;\r\n }\r\n\r\n if (selectedItemsSet.guid === guidBefore)\r\n return;\r\n\r\n container.clear(evt.level + 1);\r\n this.selectionChange.raiseEvent(evt, this);\r\n }\r\n\r\n /**\r\n * Add keys to the selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public addToSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Add,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to remove\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public removeFromSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Remove,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Replace current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public replaceSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Replace,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Clear current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public clearSelection(source: string, imodel: IModelConnection, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Clear,\r\n keys: new KeySet(),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Add keys to selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to add\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async addToSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.addToSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to remove\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async removeFromSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.removeFromSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Replace current selection with keys after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to replace with\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async replaceSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.replaceSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Get the current hilite set for the specified imodel\r\n * @public\r\n */\r\n public async getHiliteSet(imodel: IModelConnection): Promise<HiliteSet> {\r\n let provider = this._hiliteSetProviders.get(imodel);\r\n if (!provider) {\r\n provider = HiliteSetProvider.create({ imodel });\r\n this._hiliteSetProviders.set(imodel, provider);\r\n }\r\n return provider.getHiliteSet(this.getSelection(imodel));\r\n }\r\n}\r\n\r\n/** @internal */\r\nclass SelectionContainer {\r\n private readonly _selectedItemsSetMap: Map<number, KeySet>;\r\n\r\n constructor() {\r\n this._selectedItemsSetMap = new Map<number, KeySet>();\r\n }\r\n\r\n public getSelection(level: number): KeySet {\r\n let selectedItemsSet = this._selectedItemsSetMap.get(level);\r\n if (!selectedItemsSet) {\r\n selectedItemsSet = new KeySet();\r\n this._selectedItemsSetMap.set(level, selectedItemsSet);\r\n }\r\n return selectedItemsSet;\r\n }\r\n\r\n public getSelectionLevels(): number[] {\r\n const levels = new Array<number>();\r\n for (const entry of this._selectedItemsSetMap.entries()) {\r\n if (!entry[1].isEmpty)\r\n levels.push(entry[0]);\r\n }\r\n return levels.sort();\r\n }\r\n\r\n public clear(level: number) {\r\n const keys = this._selectedItemsSetMap.keys();\r\n for (const key of keys) {\r\n if (key >= level) {\r\n const selectedItemsSet = this._selectedItemsSetMap.get(key)!;\r\n selectedItemsSet.clear();\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\r\n\r\n/** @internal */\r\nexport class ToolSelectionSyncHandler implements IDisposable {\r\n\r\n private _selectionSourceName = \"Tool\";\r\n private _logicalSelection: SelectionManager;\r\n private _imodel: IModelConnection;\r\n private _imodelToolSelectionListenerDisposeFunc: () => void;\r\n private _asyncsTracker = new AsyncTasksTracker();\r\n public isSuspended?: boolean;\r\n\r\n public constructor(imodel: IModelConnection, logicalSelection: SelectionManager) {\r\n this._imodel = imodel;\r\n this._logicalSelection = logicalSelection;\r\n this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);\r\n }\r\n\r\n public dispose() {\r\n this._imodelToolSelectionListenerDisposeFunc();\r\n }\r\n\r\n /** note: used only it tests */\r\n public get pendingAsyncs() { return this._asyncsTracker.pendingAsyncs; }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onToolSelectionChanged = async (ev: SelectionSetEvent): Promise<void> => {\r\n // ignore selection change event if the handler is suspended\r\n if (this.isSuspended)\r\n return;\r\n\r\n // this component only cares about its own imodel\r\n const imodel = ev.set.iModel;\r\n if (imodel !== this._imodel)\r\n return;\r\n\r\n // determine the level of selection changes\r\n // wip: may want to allow selecting at different levels?\r\n const selectionLevel = 0;\r\n\r\n let ids: Id64Arg;\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n ids = ev.added;\r\n break;\r\n case SelectionSetEventType.Replace:\r\n ids = ev.set.elements;\r\n break;\r\n default:\r\n ids = ev.removed;\r\n break;\r\n }\r\n\r\n // we're always using scoped selection changer even if the scope is set to \"element\" - that\r\n // makes sure we're adding to selection keys with concrete classes and not \"BisCore:Element\", which\r\n // we can't because otherwise our keys compare fails (presentation components load data with\r\n // concrete classes)\r\n const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));\r\n\r\n // we know what to do immediately on `clear` events\r\n if (SelectionSetEventType.Clear === ev.type) {\r\n await changer.clear(selectionLevel);\r\n return;\r\n }\r\n\r\n const parsedIds = parseIds(ids);\r\n await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Replace:\r\n await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Remove:\r\n await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n }\r\n });\r\n };\r\n}\r\n\r\nconst parseIds = (ids: Id64Arg): { persistent: Id64Arg, transient: Id64Arg } => {\r\n let allPersistent = true;\r\n let allTransient = true;\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id))\r\n allPersistent = false;\r\n else\r\n allTransient = false;\r\n\r\n if (!allPersistent && !allTransient)\r\n break;\r\n }\r\n\r\n // avoid making a copy if ids are only persistent or only transient\r\n if (allPersistent) {\r\n return { persistent: ids, transient: [] };\r\n } else if (allTransient) {\r\n return { persistent: [], transient: ids };\r\n }\r\n\r\n // if `ids` contain mixed ids, we have to copy.. use Array instead of\r\n // a Set for performance\r\n const persistentElementIds: Id64Array = [];\r\n const transientElementIds: Id64Array = [];\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id))\r\n transientElementIds.push(id);\r\n else\r\n persistentElementIds.push(id);\r\n }\r\n\r\n return { persistent: persistentElementIds, transient: transientElementIds };\r\n};\r\n\r\nfunction addTransientKeys(transientIds: Id64Arg, keys: KeySet): void {\r\n for (const id of Id64.iterable(transientIds))\r\n keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });\r\n}\r\n\r\n/** @internal */\r\nclass ScopedSelectionChanger {\r\n public readonly name: string;\r\n public readonly imodel: IModelConnection;\r\n public readonly manager: SelectionManager;\r\n public readonly scope: SelectionScopeProps | SelectionScope | string;\r\n public constructor(name: string, imodel: IModelConnection, manager: SelectionManager, scope: SelectionScopeProps | SelectionScope | string) {\r\n this.name = name;\r\n this.imodel = imodel;\r\n this.manager = manager;\r\n this.scope = scope;\r\n }\r\n public async clear(level: number): Promise<void> {\r\n this.manager.clearSelection(this.name, this.imodel, level);\r\n }\r\n public async add(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.addToSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async remove(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.removeFromSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async replace(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.replaceSelection(this.name, this.imodel, keys, level);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SelectionManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAmF;AACnF,wDAAkG;AAClG,oEAAkH;AAClH,2DAAmE;AAEnE,iEAA6G;AAC7G,qEAA6F;AAW7F;;;GAGG;AACH,MAAa,gBAAgB;IAW3B;;OAEG;IACH,YAAY,KAA4B;QAbhC,2BAAsB,GAAG,IAAI,GAAG,EAAwC,CAAC;QACzE,qCAAgC,GAAG,IAAI,GAAG,EAAoF,CAAC;QAC/H,wBAAmB,GAAG,IAAI,GAAG,EAAuC,CAAC;QAY3E,IAAI,CAAC,eAAe,GAAG,IAAI,2CAAoB,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,gCAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAwB,EAAE,EAAE;YAChE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAwB;QAChD,IAAI,CAAC,cAAc,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEO,Y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CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module UnifiedSelection\r\n */\r\n\r\nimport { Id64, Id64Arg, Id64Array, IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection, SelectionSetEvent, SelectionSetEventType } from \"@itwin/core-frontend\";\r\nimport { AsyncTasksTracker, Keys, KeySet, SelectionScope, SelectionScopeProps } from \"@itwin/presentation-common\";\r\nimport { HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider\";\r\nimport { ISelectionProvider } from \"./ISelectionProvider\";\r\nimport { SelectionChangeEvent, SelectionChangeEventArgs, SelectionChangeType } from \"./SelectionChangeEvent\";\r\nimport { createSelectionScopeProps, SelectionScopesManager } from \"./SelectionScopesManager\";\r\n\r\n/**\r\n * Properties for creating [[SelectionManager]].\r\n * @public\r\n */\r\nexport interface SelectionManagerProps {\r\n /** A manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n scopes: SelectionScopesManager;\r\n}\r\n\r\n/**\r\n * The selection manager which stores the overall selection.\r\n * @public\r\n */\r\nexport class SelectionManager implements ISelectionProvider {\r\n private _selectionContainerMap = new Map<IModelConnection, SelectionContainer>();\r\n private _imodelToolSelectionSyncHandlers = new Map<IModelConnection, { requestorsCount: number, handler: ToolSelectionSyncHandler }>();\r\n private _hiliteSetProviders = new Map<IModelConnection, HiliteSetProvider>();\r\n\r\n /** An event which gets broadcasted on selection changes */\r\n public readonly selectionChange: SelectionChangeEvent;\r\n\r\n /** Manager for [selection scopes]($docs/presentation/unified-selection/index#selection-scopes) */\r\n public readonly scopes: SelectionScopesManager;\r\n\r\n /**\r\n * Creates an instance of SelectionManager.\r\n */\r\n constructor(props: SelectionManagerProps) {\r\n this.selectionChange = new SelectionChangeEvent();\r\n this.scopes = props.scopes;\r\n IModelConnection.onClose.addListener((imodel: IModelConnection) => {\r\n this.onConnectionClose(imodel);\r\n });\r\n }\r\n\r\n private onConnectionClose(imodel: IModelConnection): void {\r\n this.clearSelection(\"Connection Close Event\", imodel);\r\n this._selectionContainerMap.delete(imodel);\r\n this._hiliteSetProviders.delete(imodel);\r\n }\r\n\r\n private getContainer(imodel: IModelConnection): SelectionContainer {\r\n let selectionContainer = this._selectionContainerMap.get(imodel);\r\n if (!selectionContainer) {\r\n selectionContainer = new SelectionContainer();\r\n this._selectionContainerMap.set(imodel, selectionContainer);\r\n }\r\n return selectionContainer;\r\n }\r\n\r\n /** @internal */\r\n // istanbul ignore next\r\n public getToolSelectionSyncHandler(imodel: IModelConnection) { return this._imodelToolSelectionSyncHandlers.get(imodel)?.handler; }\r\n\r\n /**\r\n * Request the manager to sync with imodel's tool selection (see `IModelConnection.selectionSet`).\r\n */\r\n public setSyncWithIModelToolSelection(imodel: IModelConnection, sync = true) {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (sync) {\r\n if (!registration || registration.requestorsCount === 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { requestorsCount: 1, handler: new ToolSelectionSyncHandler(imodel, this) });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount: registration.requestorsCount + 1 });\r\n }\r\n } else {\r\n if (registration && registration.requestorsCount > 0) {\r\n const requestorsCount = registration.requestorsCount - 1;\r\n if (requestorsCount > 0) {\r\n this._imodelToolSelectionSyncHandlers.set(imodel, { ...registration, requestorsCount });\r\n } else {\r\n this._imodelToolSelectionSyncHandlers.delete(imodel);\r\n registration.handler.dispose();\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Temporarily suspends tool selection synchronization until the returned `IDisposable`\r\n * is disposed.\r\n */\r\n public suspendIModelToolSelectionSync(imodel: IModelConnection): IDisposable {\r\n const registration = this._imodelToolSelectionSyncHandlers.get(imodel);\r\n if (!registration)\r\n return { dispose: () => { } };\r\n\r\n const wasSuspended = registration.handler.isSuspended;\r\n registration.handler.isSuspended = true;\r\n return { dispose: () => (registration.handler.isSuspended = wasSuspended) };\r\n }\r\n\r\n /** Get the selection levels currently stored in this manager for the specified imodel */\r\n public getSelectionLevels(imodel: IModelConnection): number[] {\r\n return this.getContainer(imodel).getSelectionLevels();\r\n }\r\n\r\n /** Get the selection currently stored in this manager */\r\n public getSelection(imodel: IModelConnection, level: number = 0): Readonly<KeySet> {\r\n return this.getContainer(imodel).getSelection(level);\r\n }\r\n\r\n private handleEvent(evt: SelectionChangeEventArgs): void {\r\n const container = this.getContainer(evt.imodel);\r\n const selectedItemsSet = container.getSelection(evt.level);\r\n const guidBefore = selectedItemsSet.guid;\r\n switch (evt.changeType) {\r\n case SelectionChangeType.Add:\r\n selectedItemsSet.add(evt.keys);\r\n break;\r\n case SelectionChangeType.Remove:\r\n selectedItemsSet.delete(evt.keys);\r\n break;\r\n case SelectionChangeType.Replace:\r\n if (selectedItemsSet.size !== evt.keys.size || !selectedItemsSet.hasAll(evt.keys)) {\r\n // note: the above check is only needed to avoid changing\r\n // guid of the keyset if we're replacing keyset with the same keys\r\n selectedItemsSet.clear().add(evt.keys);\r\n }\r\n break;\r\n case SelectionChangeType.Clear:\r\n selectedItemsSet.clear();\r\n break;\r\n }\r\n\r\n if (selectedItemsSet.guid === guidBefore)\r\n return;\r\n\r\n container.clear(evt.level + 1);\r\n this.selectionChange.raiseEvent(evt, this);\r\n }\r\n\r\n /**\r\n * Add keys to the selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public addToSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Add,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to remove\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public removeFromSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Remove,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Replace current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param keys Keys to add\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public replaceSelection(source: string, imodel: IModelConnection, keys: Keys, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Replace,\r\n keys: new KeySet(keys),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Clear current selection\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public clearSelection(source: string, imodel: IModelConnection, level: number = 0, rulesetId?: string): void {\r\n const evt: SelectionChangeEventArgs = {\r\n source,\r\n level,\r\n imodel,\r\n changeType: SelectionChangeType.Clear,\r\n keys: new KeySet(),\r\n timestamp: new Date(),\r\n rulesetId,\r\n };\r\n this.handleEvent(evt);\r\n }\r\n\r\n /**\r\n * Add keys to selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to add\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async addToSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.addToSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Remove keys from current selection after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to remove\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async removeFromSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.removeFromSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Replace current selection with keys after applying [selection scope]($docs/presentation/unified-selection/index#selection-scopes) on them.\r\n * @param source Name of the selection source\r\n * @param imodel iModel associated with the selection\r\n * @param ids Element IDs to replace with\r\n * @param scope Selection scope to apply\r\n * @param level Selection level (see [selection levels documentation section]($docs/presentation/unified-selection/index#selection-levels))\r\n * @param rulesetId ID of the ruleset in case the selection was changed from a rules-driven control\r\n */\r\n public async replaceSelectionWithScope(source: string, imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string, level: number = 0, rulesetId?: string): Promise<void> {\r\n const scopedKeys = await this.scopes.computeSelection(imodel, ids, scope);\r\n this.replaceSelection(source, imodel, scopedKeys, level, rulesetId);\r\n }\r\n\r\n /**\r\n * Get the current hilite set for the specified imodel\r\n * @public\r\n */\r\n public async getHiliteSet(imodel: IModelConnection): Promise<HiliteSet> {\r\n let provider = this._hiliteSetProviders.get(imodel);\r\n if (!provider) {\r\n provider = HiliteSetProvider.create({ imodel });\r\n this._hiliteSetProviders.set(imodel, provider);\r\n }\r\n return provider.getHiliteSet(this.getSelection(imodel));\r\n }\r\n}\r\n\r\n/** @internal */\r\nclass SelectionContainer {\r\n private readonly _selectedItemsSetMap: Map<number, KeySet>;\r\n\r\n constructor() {\r\n this._selectedItemsSetMap = new Map<number, KeySet>();\r\n }\r\n\r\n public getSelection(level: number): KeySet {\r\n let selectedItemsSet = this._selectedItemsSetMap.get(level);\r\n if (!selectedItemsSet) {\r\n selectedItemsSet = new KeySet();\r\n this._selectedItemsSetMap.set(level, selectedItemsSet);\r\n }\r\n return selectedItemsSet;\r\n }\r\n\r\n public getSelectionLevels(): number[] {\r\n const levels = new Array<number>();\r\n for (const entry of this._selectedItemsSetMap.entries()) {\r\n if (!entry[1].isEmpty)\r\n levels.push(entry[0]);\r\n }\r\n return levels.sort();\r\n }\r\n\r\n public clear(level: number) {\r\n const keys = this._selectedItemsSetMap.keys();\r\n for (const key of keys) {\r\n if (key >= level) {\r\n const selectedItemsSet = this._selectedItemsSetMap.get(key)!;\r\n selectedItemsSet.clear();\r\n }\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\r\n\r\n/** @internal */\r\nexport class ToolSelectionSyncHandler implements IDisposable {\r\n\r\n private _selectionSourceName = \"Tool\";\r\n private _logicalSelection: SelectionManager;\r\n private _imodel: IModelConnection;\r\n private _imodelToolSelectionListenerDisposeFunc: () => void;\r\n private _asyncsTracker = new AsyncTasksTracker();\r\n public isSuspended?: boolean;\r\n\r\n public constructor(imodel: IModelConnection, logicalSelection: SelectionManager) {\r\n this._imodel = imodel;\r\n this._logicalSelection = logicalSelection;\r\n this._imodelToolSelectionListenerDisposeFunc = imodel.selectionSet.onChanged.addListener(this.onToolSelectionChanged);\r\n }\r\n\r\n public dispose() {\r\n this._imodelToolSelectionListenerDisposeFunc();\r\n }\r\n\r\n /** note: used only it tests */\r\n public get pendingAsyncs() { return this._asyncsTracker.pendingAsyncs; }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onToolSelectionChanged = async (ev: SelectionSetEvent): Promise<void> => {\r\n // ignore selection change event if the handler is suspended\r\n if (this.isSuspended)\r\n return;\r\n\r\n // this component only cares about its own imodel\r\n const imodel = ev.set.iModel;\r\n if (imodel !== this._imodel)\r\n return;\r\n\r\n // determine the level of selection changes\r\n // wip: may want to allow selecting at different levels?\r\n const selectionLevel = 0;\r\n\r\n let ids: Id64Arg;\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n ids = ev.added;\r\n break;\r\n case SelectionSetEventType.Replace:\r\n ids = ev.set.elements;\r\n break;\r\n default:\r\n ids = ev.removed;\r\n break;\r\n }\r\n\r\n // we're always using scoped selection changer even if the scope is set to \"element\" - that\r\n // makes sure we're adding to selection keys with concrete classes and not \"BisCore:Element\", which\r\n // we can't because otherwise our keys compare fails (presentation components load data with\r\n // concrete classes)\r\n const changer = new ScopedSelectionChanger(this._selectionSourceName, this._imodel, this._logicalSelection, createSelectionScopeProps(this._logicalSelection.scopes.activeScope));\r\n\r\n // we know what to do immediately on `clear` events\r\n if (SelectionSetEventType.Clear === ev.type) {\r\n await changer.clear(selectionLevel);\r\n return;\r\n }\r\n\r\n const parsedIds = parseIds(ids);\r\n await using(this._asyncsTracker.trackAsyncTask(), async (_r) => {\r\n switch (ev.type) {\r\n case SelectionSetEventType.Add:\r\n await changer.add(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Replace:\r\n await changer.replace(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n case SelectionSetEventType.Remove:\r\n await changer.remove(parsedIds.transient, parsedIds.persistent, selectionLevel);\r\n break;\r\n }\r\n });\r\n };\r\n}\r\n\r\nconst parseIds = (ids: Id64Arg): { persistent: Id64Arg, transient: Id64Arg } => {\r\n let allPersistent = true;\r\n let allTransient = true;\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id))\r\n allPersistent = false;\r\n else\r\n allTransient = false;\r\n\r\n if (!allPersistent && !allTransient)\r\n break;\r\n }\r\n\r\n // avoid making a copy if ids are only persistent or only transient\r\n if (allPersistent) {\r\n return { persistent: ids, transient: [] };\r\n } else if (allTransient) {\r\n return { persistent: [], transient: ids };\r\n }\r\n\r\n // if `ids` contain mixed ids, we have to copy.. use Array instead of\r\n // a Set for performance\r\n const persistentElementIds: Id64Array = [];\r\n const transientElementIds: Id64Array = [];\r\n for (const id of Id64.iterable(ids)) {\r\n if (Id64.isTransient(id))\r\n transientElementIds.push(id);\r\n else\r\n persistentElementIds.push(id);\r\n }\r\n\r\n return { persistent: persistentElementIds, transient: transientElementIds };\r\n};\r\n\r\nfunction addTransientKeys(transientIds: Id64Arg, keys: KeySet): void {\r\n for (const id of Id64.iterable(transientIds))\r\n keys.add({ className: TRANSIENT_ELEMENT_CLASSNAME, id });\r\n}\r\n\r\n/** @internal */\r\nclass ScopedSelectionChanger {\r\n public readonly name: string;\r\n public readonly imodel: IModelConnection;\r\n public readonly manager: SelectionManager;\r\n public readonly scope: SelectionScopeProps | SelectionScope | string;\r\n public constructor(name: string, imodel: IModelConnection, manager: SelectionManager, scope: SelectionScopeProps | SelectionScope | string) {\r\n this.name = name;\r\n this.imodel = imodel;\r\n this.manager = manager;\r\n this.scope = scope;\r\n }\r\n public async clear(level: number): Promise<void> {\r\n this.manager.clearSelection(this.name, this.imodel, level);\r\n }\r\n public async add(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.addToSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async remove(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.removeFromSelection(this.name, this.imodel, keys, level);\r\n }\r\n public async replace(transientIds: Id64Arg, persistentIds: Id64Arg, level: number): Promise<void> {\r\n const keys = await this.manager.scopes.computeSelection(this.imodel, persistentIds, this.scope);\r\n addTransientKeys(transientIds, keys);\r\n this.manager.replaceSelection(this.name, this.imodel, keys, level);\r\n }\r\n}\r\n"]}
@@ -44,10 +44,10 @@ export declare class SelectionScopesManager {
44
44
  computeSelection(imodel: IModelConnection, ids: Id64Arg, scope: SelectionScopeProps | SelectionScope | string): Promise<KeySet>;
45
45
  }
46
46
  /**
47
- * Normalizes given scope options and returns [[ComputeSelectionScopeProps]] that can be used for
47
+ * Normalizes given scope options and returns [[SelectionScopeProps]] that can be used for
48
48
  * calculating selection with scope.
49
49
  *
50
- * @internal
50
+ * @public
51
51
  */
52
52
  export declare function createSelectionScopeProps(scope: SelectionScopeProps | SelectionScope | string | undefined): SelectionScopeProps;
53
53
  /**
@@ -65,10 +65,10 @@ class SelectionScopesManager {
65
65
  }
66
66
  exports.SelectionScopesManager = SelectionScopesManager;
67
67
  /**
68
- * Normalizes given scope options and returns [[ComputeSelectionScopeProps]] that can be used for
68
+ * Normalizes given scope options and returns [[SelectionScopeProps]] that can be used for
69
69
  * calculating selection with scope.
70
70
  *
71
- * @internal
71
+ * @public
72
72
  */
73
73
  function createSelectionScopeProps(scope) {
74
74
  if (!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,oEAAsI;AActI;;;;;GAKG;AACH,MAAa,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,EAAE,MAAe;QACvE,IAAI,CAAC,MAAM;YACT,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,gBAAgB,CAAC,MAAwB,EAAE,GAAY,EAAE,KAAoD;QACxH,MAAM,UAAU,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC;QAEpD,6BAA6B;QAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ;YACzB,GAAG,GAAG,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AAG,CAAC,EAAE,CAAC,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA1DD,wDA0DC;AAED;;;;;GAKG;AACH,SAAgB,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;AAND,8DAMC;AAED;;;;;GAKG;AACH,uBAAuB;AACvB,SAAgB,UAAU,CAAC,KAA0C;IACnE,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC;AAFD,gCAEC","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"]}
1
+ {"version":3,"file":"SelectionScopesManager.js","sourceRoot":"","sources":["../../../../src/presentation-frontend/selection/SelectionScopesManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,oEAAsI;AActI;;;;;GAKG;AACH,MAAa,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,CAA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,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,UAAU,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,4BAAM,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;AA1DD,wDA0DC;AAED;;;;;GAKG;AACH,SAAgB,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;AAND,8DAMC;AAED;;;;;GAKG;AACH,uBAAuB;AACvB,SAAgB,UAAU,CAAC,KAA0C;IACnE,OAAO,yBAAyB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AAC7C,CAAC;AAFD,gCAEC","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 [[SelectionScopeProps]] that can be used for\r\n * calculating selection with scope.\r\n *\r\n * @public\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"]}
@@ -39,6 +39,6 @@ export class ConnectivityInformationProvider {
39
39
  dispose() {
40
40
  this._unsubscribeFromInternetConnectivityChangedEvent && this._unsubscribeFromInternetConnectivityChangedEvent();
41
41
  }
42
- get status() { var _a; return (_a = this._currentStatus) !== null && _a !== void 0 ? _a : InternetConnectivityStatus.Offline; }
42
+ get status() { return this._currentStatus ?? InternetConnectivityStatus.Offline; }
43
43
  }
44
44
  //# sourceMappingURL=ConnectivityInformationProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectivityInformationProvider.js","sourceRoot":"","sources":["../../../src/presentation-frontend/ConnectivityInformationProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAe,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAQjD;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAM1C;QAFgB,kCAA6B,GAAG,IAAI,OAAO,EAA0D,CAAC;QAmBtH,gEAAgE;QACxD,2CAAsC,GAAG,CAAC,MAAkC,EAAE,EAAE;YACtF,IAAI,IAAI,CAAC,cAAc,KAAK,MAAM;gBAChC,OAAO;YAET,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;YAC7B,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC;QAvBA,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,IAAI,CAAC,gDAAgD,GAAG,SAAS,CAAC,6BAA6B,CAAC,WAAW,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;YACzJ,mEAAmE;YACnE,SAAS,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,CAAC,MAAkC,EAAE,EAAE;gBAChF,IAAI,SAAS,KAAK,IAAI,CAAC,cAAc;oBACnC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;YACjC,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,cAAc,GAAG,0BAA0B,CAAC,MAAM,CAAC;SACzD;IACH,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,gDAAgD,IAAI,IAAI,CAAC,gDAAgD,EAAE,CAAC;IACnH,CAAC;IAWD,IAAW,MAAM,aAAiC,OAAO,MAAA,IAAI,CAAC,cAAc,mCAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;CACtH","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, IDisposable } from \"@itwin/core-bentley\";\r\nimport { InternetConnectivityStatus } from \"@itwin/core-common\";\r\nimport { NativeApp } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport interface IConnectivityInformationProvider {\r\n readonly status: InternetConnectivityStatus;\r\n readonly onInternetConnectivityChanged: BeEvent<(args: { status: InternetConnectivityStatus }) => void>;\r\n}\r\n\r\n/**\r\n * A helper that wraps connectivity-related APIs in NativeApp\r\n * to give a unified information for interested parties in presentation.\r\n *\r\n * @internal\r\n */\r\nexport class ConnectivityInformationProvider implements IConnectivityInformationProvider, IDisposable {\r\n\r\n private _currentStatus?: InternetConnectivityStatus;\r\n private _unsubscribeFromInternetConnectivityChangedEvent?: () => void;\r\n public readonly onInternetConnectivityChanged = new BeEvent<(args: { status: InternetConnectivityStatus }) => void>();\r\n\r\n public constructor() {\r\n if (NativeApp.isValid) {\r\n this._unsubscribeFromInternetConnectivityChangedEvent = NativeApp.onInternetConnectivityChanged.addListener(this.onNativeAppInternetConnectivityChanged);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n NativeApp.checkInternetConnectivity().then((status: InternetConnectivityStatus) => {\r\n if (undefined === this._currentStatus)\r\n this._currentStatus = status;\r\n });\r\n } else {\r\n this._currentStatus = InternetConnectivityStatus.Online;\r\n }\r\n }\r\n\r\n public dispose() {\r\n this._unsubscribeFromInternetConnectivityChangedEvent && this._unsubscribeFromInternetConnectivityChangedEvent();\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onNativeAppInternetConnectivityChanged = (status: InternetConnectivityStatus) => {\r\n if (this._currentStatus === status)\r\n return;\r\n\r\n this._currentStatus = status;\r\n this.onInternetConnectivityChanged.raiseEvent({ status });\r\n };\r\n\r\n public get status(): InternetConnectivityStatus { return this._currentStatus ?? InternetConnectivityStatus.Offline; }\r\n}\r\n"]}
1
+ {"version":3,"file":"ConnectivityInformationProvider.js","sourceRoot":"","sources":["../../../src/presentation-frontend/ConnectivityInformationProvider.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAe,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAQjD;;;;;GAKG;AACH,MAAM,OAAO,+BAA+B;IAM1C;QAFgB,kCAA6B,GAAG,IAAI,OAAO,EAA0D,CAAC;QAmBtH,gEAAgE;QACxD,2CAAsC,GAAG,CAAC,MAAkC,EAAE,EAAE;YACtF,IAAI,IAAI,CAAC,cAAc,KAAK,MAAM;gBAChC,OAAO;YAET,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;YAC7B,IAAI,CAAC,6BAA6B,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAC5D,CAAC,CAAC;QAvBA,IAAI,SAAS,CAAC,OAAO,EAAE;YACrB,IAAI,CAAC,gDAAgD,GAAG,SAAS,CAAC,6BAA6B,CAAC,WAAW,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;YACzJ,mEAAmE;YACnE,SAAS,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,CAAC,MAAkC,EAAE,EAAE;gBAChF,IAAI,SAAS,KAAK,IAAI,CAAC,cAAc;oBACnC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;YACjC,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,cAAc,GAAG,0BAA0B,CAAC,MAAM,CAAC;SACzD;IACH,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,gDAAgD,IAAI,IAAI,CAAC,gDAAgD,EAAE,CAAC;IACnH,CAAC;IAWD,IAAW,MAAM,KAAiC,OAAO,IAAI,CAAC,cAAc,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC,CAAC;CACtH","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, IDisposable } from \"@itwin/core-bentley\";\r\nimport { InternetConnectivityStatus } from \"@itwin/core-common\";\r\nimport { NativeApp } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport interface IConnectivityInformationProvider {\r\n readonly status: InternetConnectivityStatus;\r\n readonly onInternetConnectivityChanged: BeEvent<(args: { status: InternetConnectivityStatus }) => void>;\r\n}\r\n\r\n/**\r\n * A helper that wraps connectivity-related APIs in NativeApp\r\n * to give a unified information for interested parties in presentation.\r\n *\r\n * @internal\r\n */\r\nexport class ConnectivityInformationProvider implements IConnectivityInformationProvider, IDisposable {\r\n\r\n private _currentStatus?: InternetConnectivityStatus;\r\n private _unsubscribeFromInternetConnectivityChangedEvent?: () => void;\r\n public readonly onInternetConnectivityChanged = new BeEvent<(args: { status: InternetConnectivityStatus }) => void>();\r\n\r\n public constructor() {\r\n if (NativeApp.isValid) {\r\n this._unsubscribeFromInternetConnectivityChangedEvent = NativeApp.onInternetConnectivityChanged.addListener(this.onNativeAppInternetConnectivityChanged);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n NativeApp.checkInternetConnectivity().then((status: InternetConnectivityStatus) => {\r\n if (undefined === this._currentStatus)\r\n this._currentStatus = status;\r\n });\r\n } else {\r\n this._currentStatus = InternetConnectivityStatus.Online;\r\n }\r\n }\r\n\r\n public dispose() {\r\n this._unsubscribeFromInternetConnectivityChangedEvent && this._unsubscribeFromInternetConnectivityChangedEvent();\r\n }\r\n\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n private onNativeAppInternetConnectivityChanged = (status: InternetConnectivityStatus) => {\r\n if (this._currentStatus === status)\r\n return;\r\n\r\n this._currentStatus = status;\r\n this.onInternetConnectivityChanged.raiseEvent({ status });\r\n };\r\n\r\n public get status(): InternetConnectivityStatus { return this._currentStatus ?? InternetConnectivityStatus.Offline; }\r\n}\r\n"]}
@@ -47,8 +47,6 @@ export declare class Presentation {
47
47
  /**
48
48
  * Registers an additional handler which will be invoked during Presentation library frontend
49
49
  * initialization.
50
- *
51
- * @internal
52
50
  */
53
51
  static registerInitializationHandler(handler: () => Promise<() => void>): void;
54
52
  /** The singleton [[PresentationManager]] */
@@ -1 +1 @@
1
- {"version":3,"file":"Presentation.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/Presentation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAE,8BAA8B,EAAE,MAAM,iDAAiD,CAAC;AAG5H,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAUvF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,YAAY,CAAC,EAAE,wBAAwB,CAAC;IAExC,sCAAsC;IACtC,SAAS,CAAC,EAAE,qBAAqB,CAAC;IAElC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,8BAA8B,CAAC;CAC5C;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAY;IAGvB,OAAO;IAEP;;;;;;;;;OASG;WACiB,UAAU,CAA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