@itwin/unified-selection
Advanced tools
Comparing version 1.0.0 to 1.0.1
# @itwin/unified-selection | ||
## 1.0.1 | ||
### Patch Changes | ||
- [#730](https://github.com/iTwin/presentation/pull/730): Fix provider returned by `createHiliteSetProvider` in some cases not caching class hierarchy check results, resulting in duplicate checks for the same classes. | ||
## 1.0.0 | ||
@@ -4,0 +10,0 @@ |
@@ -10,2 +10,3 @@ "use strict"; | ||
const rxjs_for_await_1 = require("rxjs-for-await"); | ||
const presentation_shared_1 = require("@itwin/presentation-shared"); | ||
const Utils_1 = require("./Utils"); | ||
@@ -78,24 +79,25 @@ const HILITE_SET_EMIT_FREQUENCY = 20; | ||
async getType(key) { | ||
const cachedType = this._classRelationCache.get(key.className.replace(".", ":")); | ||
const normalizedClassName = (0, presentation_shared_1.normalizeFullClassName)(key.className); | ||
const cachedType = this._classRelationCache.get(normalizedClassName); | ||
if (cachedType) { | ||
return cachedType; | ||
} | ||
const promise = this.getTypeImpl(key).then((res) => { | ||
const promise = this.getTypeImpl(normalizedClassName).then((res) => { | ||
// Update the cache with the result of the promise. | ||
this._classRelationCache.set(key.className, res); | ||
this._classRelationCache.set(normalizedClassName, res); | ||
return res; | ||
}); | ||
// Add the promise to cache to prevent `getTypeImpl` being called multiple times. | ||
this._classRelationCache.set(key.className, promise); | ||
this._classRelationCache.set(normalizedClassName, promise); | ||
return promise; | ||
} | ||
async getTypeImpl(key) { | ||
return ((await this.checkType(key.className, "BisCore.Subject", "subject")) ?? | ||
(await this.checkType(key.className, "BisCore.Model", "model")) ?? | ||
(await this.checkType(key.className, "BisCore.Category", "category")) ?? | ||
(await this.checkType(key.className, "BisCore.SubCategory", "subCategory")) ?? | ||
(await this.checkType(key.className, "Functional.FunctionalElement", "functionalElement")) ?? | ||
(await this.checkType(key.className, "BisCore.GroupInformationElement", "groupInformationElement")) ?? | ||
(await this.checkType(key.className, "BisCore.GeometricElement", "geometricElement")) ?? | ||
(await this.checkType(key.className, "BisCore.Element", "element")) ?? | ||
async getTypeImpl(fullClassName) { | ||
return ((await this.checkType(fullClassName, "BisCore.Subject", "subject")) ?? | ||
(await this.checkType(fullClassName, "BisCore.Model", "model")) ?? | ||
(await this.checkType(fullClassName, "BisCore.Category", "category")) ?? | ||
(await this.checkType(fullClassName, "BisCore.SubCategory", "subCategory")) ?? | ||
(await this.checkType(fullClassName, "Functional.FunctionalElement", "functionalElement")) ?? | ||
(await this.checkType(fullClassName, "BisCore.GroupInformationElement", "groupInformationElement")) ?? | ||
(await this.checkType(fullClassName, "BisCore.GeometricElement", "geometricElement")) ?? | ||
(await this.checkType(fullClassName, "BisCore.Element", "element")) ?? | ||
"unknown"); | ||
@@ -102,0 +104,0 @@ } |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.Selectables = exports.Selectable = void 0; | ||
const presentation_shared_1 = require("@itwin/presentation-shared"); | ||
/** @beta */ | ||
@@ -71,3 +72,3 @@ // eslint-disable-next-line @typescript-eslint/no-redeclare | ||
if (Selectable.isInstanceKey(value)) { | ||
const normalizedClassName = normalizeClassName(value.className); | ||
const normalizedClassName = (0, presentation_shared_1.normalizeFullClassName)(value.className); | ||
const set = selectables.instanceKeys.get(normalizedClassName); | ||
@@ -122,3 +123,3 @@ return !!(set && set.has(value.id)); | ||
if (Selectable.isInstanceKey(selectable)) { | ||
const normalizedClassName = normalizeClassName(selectable.className); | ||
const normalizedClassName = (0, presentation_shared_1.normalizeFullClassName)(selectable.className); | ||
let set = selectables.instanceKeys.get(normalizedClassName); | ||
@@ -152,3 +153,3 @@ if (!set) { | ||
if (Selectable.isInstanceKey(selectable)) { | ||
const normalizedClassName = normalizeClassName(selectable.className); | ||
const normalizedClassName = (0, presentation_shared_1.normalizeFullClassName)(selectable.className); | ||
const set = selectables.instanceKeys.get(normalizedClassName); | ||
@@ -221,6 +222,3 @@ if (set && set.has(selectable.id)) { | ||
Selectables.forEach = forEach; | ||
function normalizeClassName(className) { | ||
return className.replace(".", ":"); | ||
} | ||
})(Selectables || (exports.Selectables = Selectables = {})); | ||
//# sourceMappingURL=Selectable.js.map |
@@ -7,2 +7,3 @@ /*--------------------------------------------------------------------------------------------- | ||
import { eachValueFrom } from "rxjs-for-await"; | ||
import { normalizeFullClassName } from "@itwin/presentation-shared"; | ||
import { formIdBindings, genericExecuteQuery, releaseMainThreadOnItemsCount } from "./Utils"; | ||
@@ -75,24 +76,25 @@ const HILITE_SET_EMIT_FREQUENCY = 20; | ||
async getType(key) { | ||
const cachedType = this._classRelationCache.get(key.className.replace(".", ":")); | ||
const normalizedClassName = normalizeFullClassName(key.className); | ||
const cachedType = this._classRelationCache.get(normalizedClassName); | ||
if (cachedType) { | ||
return cachedType; | ||
} | ||
const promise = this.getTypeImpl(key).then((res) => { | ||
const promise = this.getTypeImpl(normalizedClassName).then((res) => { | ||
// Update the cache with the result of the promise. | ||
this._classRelationCache.set(key.className, res); | ||
this._classRelationCache.set(normalizedClassName, res); | ||
return res; | ||
}); | ||
// Add the promise to cache to prevent `getTypeImpl` being called multiple times. | ||
this._classRelationCache.set(key.className, promise); | ||
this._classRelationCache.set(normalizedClassName, promise); | ||
return promise; | ||
} | ||
async getTypeImpl(key) { | ||
return ((await this.checkType(key.className, "BisCore.Subject", "subject")) ?? | ||
(await this.checkType(key.className, "BisCore.Model", "model")) ?? | ||
(await this.checkType(key.className, "BisCore.Category", "category")) ?? | ||
(await this.checkType(key.className, "BisCore.SubCategory", "subCategory")) ?? | ||
(await this.checkType(key.className, "Functional.FunctionalElement", "functionalElement")) ?? | ||
(await this.checkType(key.className, "BisCore.GroupInformationElement", "groupInformationElement")) ?? | ||
(await this.checkType(key.className, "BisCore.GeometricElement", "geometricElement")) ?? | ||
(await this.checkType(key.className, "BisCore.Element", "element")) ?? | ||
async getTypeImpl(fullClassName) { | ||
return ((await this.checkType(fullClassName, "BisCore.Subject", "subject")) ?? | ||
(await this.checkType(fullClassName, "BisCore.Model", "model")) ?? | ||
(await this.checkType(fullClassName, "BisCore.Category", "category")) ?? | ||
(await this.checkType(fullClassName, "BisCore.SubCategory", "subCategory")) ?? | ||
(await this.checkType(fullClassName, "Functional.FunctionalElement", "functionalElement")) ?? | ||
(await this.checkType(fullClassName, "BisCore.GroupInformationElement", "groupInformationElement")) ?? | ||
(await this.checkType(fullClassName, "BisCore.GeometricElement", "geometricElement")) ?? | ||
(await this.checkType(fullClassName, "BisCore.Element", "element")) ?? | ||
"unknown"); | ||
@@ -99,0 +101,0 @@ } |
@@ -5,2 +5,3 @@ /*--------------------------------------------------------------------------------------------- | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { normalizeFullClassName } from "@itwin/presentation-shared"; | ||
/** @beta */ | ||
@@ -68,3 +69,3 @@ // eslint-disable-next-line @typescript-eslint/no-redeclare | ||
if (Selectable.isInstanceKey(value)) { | ||
const normalizedClassName = normalizeClassName(value.className); | ||
const normalizedClassName = normalizeFullClassName(value.className); | ||
const set = selectables.instanceKeys.get(normalizedClassName); | ||
@@ -119,3 +120,3 @@ return !!(set && set.has(value.id)); | ||
if (Selectable.isInstanceKey(selectable)) { | ||
const normalizedClassName = normalizeClassName(selectable.className); | ||
const normalizedClassName = normalizeFullClassName(selectable.className); | ||
let set = selectables.instanceKeys.get(normalizedClassName); | ||
@@ -149,3 +150,3 @@ if (!set) { | ||
if (Selectable.isInstanceKey(selectable)) { | ||
const normalizedClassName = normalizeClassName(selectable.className); | ||
const normalizedClassName = normalizeFullClassName(selectable.className); | ||
const set = selectables.instanceKeys.get(normalizedClassName); | ||
@@ -218,6 +219,3 @@ if (set && set.has(selectable.id)) { | ||
Selectables.forEach = forEach; | ||
function normalizeClassName(className) { | ||
return className.replace(".", ":"); | ||
} | ||
})(Selectables || (Selectables = {})); | ||
//# sourceMappingURL=Selectable.js.map |
{ | ||
"name": "@itwin/unified-selection", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Package for managing unified selection in iTwin.js applications.", | ||
@@ -66,3 +66,4 @@ "license": "MIT", | ||
"lint": "eslint ./src/**/*.ts", | ||
"test": "mocha --enable-source-maps --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"", | ||
"test": "mocha --enable-source-maps --config ./.mocharc.json", | ||
"test:dev": "mocha --enable-source-maps --config ./.mocharc.json", | ||
"test:watch": "npm -s test -- --reporter min --watch-extensions ts --watch", | ||
@@ -69,0 +70,0 @@ "extract-api": "extract-api --entry=unified-selection --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
417503