@itwin/unified-selection 1.7.6 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/lib/cjs/unified-selection/IModelHiliteSetProvider.d.ts.map +1 -1
- package/lib/cjs/unified-selection/IModelHiliteSetProvider.js +1 -1
- package/lib/cjs/unified-selection/IModelHiliteSetProvider.js.map +1 -1
- package/lib/cjs/unified-selection/Selectable.d.ts.map +1 -1
- package/lib/cjs/unified-selection/Selectable.js +2 -1
- package/lib/cjs/unified-selection/Selectable.js.map +1 -1
- package/lib/cjs/unified-selection/SelectionStorage.d.ts +5 -2
- package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
- package/lib/cjs/unified-selection/SelectionStorage.js +7 -4
- package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
- package/lib/cjs/unified-selection.d.ts +1 -0
- package/lib/cjs/unified-selection.d.ts.map +1 -1
- package/lib/cjs/unified-selection.js +3 -1
- package/lib/cjs/unified-selection.js.map +1 -1
- package/lib/esm/unified-selection/IModelHiliteSetProvider.d.ts.map +1 -1
- package/lib/esm/unified-selection/IModelHiliteSetProvider.js +2 -2
- package/lib/esm/unified-selection/IModelHiliteSetProvider.js.map +1 -1
- package/lib/esm/unified-selection/Selectable.d.ts.map +1 -1
- package/lib/esm/unified-selection/Selectable.js +2 -1
- package/lib/esm/unified-selection/Selectable.js.map +1 -1
- package/lib/esm/unified-selection/SelectionStorage.d.ts +5 -2
- package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
- package/lib/esm/unified-selection/SelectionStorage.js +6 -3
- package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
- package/lib/esm/unified-selection.d.ts +1 -0
- package/lib/esm/unified-selection.d.ts.map +1 -1
- package/lib/esm/unified-selection.js +1 -0
- package/lib/esm/unified-selection.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @itwin/unified-selection
|
|
2
2
|
|
|
3
|
+
## 1.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9f2f1f405e82bbb5bad83de67c265ea0407d6cf1: Avoid freezing main thread when loading huge amount of selectable instance keys.
|
|
8
|
+
|
|
9
|
+
## 1.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#1396](https://github.com/iTwin/presentation/pull/1396): Expose `CLEAR_SELECTION_STORAGE_SOURCE` constant that is used as selection change event source when selection storage is cleared. This should allow consumers to detect when selection change happened due to selection storage being cleared.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import {
|
|
17
|
+
createStorage,
|
|
18
|
+
CLEAR_SELECTION_STORAGE_SOURCE,
|
|
19
|
+
} from "@itwin/unified-selection";
|
|
20
|
+
|
|
21
|
+
const storage = createStorage();
|
|
22
|
+
storage.selectionChangeEvent.addListener((args) => {
|
|
23
|
+
if (args.source === CLEAR_SELECTION_STORAGE_SOURCE) {
|
|
24
|
+
// ignore change if it was caused by clearing selection storage
|
|
25
|
+
}
|
|
26
|
+
// handle selection change
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// this will trigger the `selectionChangeEvent` with `{ source: CLEAR_SELECTION_STORAGE_SOURCE }`
|
|
30
|
+
storage.clearStorage({ imodelKey: imodel.key });
|
|
31
|
+
```
|
|
32
|
+
|
|
3
33
|
## 1.7.6
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,
|
|
1
|
+
{"version":3,"file":"IModelHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAkC,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzF;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,8DAA8D;IAC9D,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,iEAAiE;IACjE,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,GAAG,kBAAkB,CAAC;IAEtF,yHAAyH;IACzH,uBAAuB,CAAC,EAAE,OAAO,uBAAuB,CAAC;CAC1D;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACtC,4DAA4D;IAC5D,oBAAoB,CAAC,KAAK,EAAE;QAC1B,4CAA4C;QAC5C,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,iBAAiB,CAAC;IAEtB,gFAAgF;IAChF,mBAAmB,CAAC,KAAK,EAAE;QACzB,mCAAmC;QACnC,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAErC;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,4BAA4B,GAAG,uBAAuB,CAE1G"}
|
|
@@ -33,7 +33,7 @@ class IModelHiliteSetProviderImpl {
|
|
|
33
33
|
this._imodelProvider = props.imodelProvider;
|
|
34
34
|
this._removeListener = this._selectionStorage.selectionChangeEvent.addListener((args) => {
|
|
35
35
|
this._cache.delete(args.imodelKey);
|
|
36
|
-
if (args.changeType === "clear" && args.source === SelectionStorage_js_1.
|
|
36
|
+
if (args.changeType === "clear" && args.source === SelectionStorage_js_1.CLEAR_SELECTION_STORAGE_SOURCE) {
|
|
37
37
|
this._hiliteSetProviders.delete(args.imodelKey);
|
|
38
38
|
}
|
|
39
39
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA8DhG,sEAEC;AA9DD,gCAA8B;AAE9B,+BAAqD;AACrD,mDAA+C;AAE/C,iEAA+F;AAE/F,+
|
|
1
|
+
{"version":3,"file":"IModelHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;AA8DhG,sEAEC;AA9DD,gCAA8B;AAE9B,+BAAqD;AACrD,mDAA+C;AAE/C,iEAA+F;AAE/F,+DAAyF;AA6CzF;;;;;;;GAOG;AACH,SAAgB,6BAA6B,CAAC,KAAmC;IAC/E,OAAO,IAAI,2BAA2B,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,2BAA2B;IACvB,iBAAiB,CAAmB;IACpC,mBAAmB,GAAG,IAAI,GAAG,EAA6B,CAAC;IAC3D,MAAM,GAAG,IAAI,GAAG,EAAiC,CAAC;IAClD,eAAe,CAAa;IAC5B,eAAe,CAAwE;IACvF,wBAAwB,CAAiC;IAEjE,YAAY,KAAmC;QAC7C,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC,gBAAgB,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC;QAC5C,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,WAAW,CAC5E,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Q,EAAE,IAAI,EAAE,CAAC,CAChC,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,IAAA,8BAAa,EAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./DisposePolyfill.js\";\n\nimport { from, Observable, shareReplay } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { ECClassHierarchyInspector, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider.js\";\nimport { StorageSelectionChangeEventArgs } from \"./SelectionChangeEvent.js\";\nimport { CLEAR_SELECTION_STORAGE_SOURCE, SelectionStorage } from \"./SelectionStorage.js\";\n\n/**\n * Props for creating an `IModelHiliteSetProvider` instance.\n * @public\n */\nexport interface IModelHiliteSetProviderProps {\n /** Selection storage to use for retrieving the hilite set. */\n selectionStorage: SelectionStorage;\n\n /** A callback that should return iModel access by iModel key. */\n imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n\n /** An optional hilite set provider factory. If not provided, defaults to `createHiliteSetProvider` from this package. */\n createHiliteSetProvider?: typeof createHiliteSetProvider;\n}\n\n/**\n * Defines return value of `createIModelHiliteSetProvider`.\n *\n * **Warning:** Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n *\n * @see `createIModelHiliteSetProvider`\n * @public\n */\nexport interface IModelHiliteSetProvider {\n /** Get the hilite set provider for the specified iModel. */\n getHiliteSetProvider(props: {\n /** iModel to get hilite set provider for */\n imodelKey: string;\n }): HiliteSetProvider;\n\n /** Get the hilite set iterator for active selection in the specified iModel. */\n getCurrentHiliteSet(props: {\n /** iModel to get hilite set for */\n imodelKey: string;\n }): AsyncIterableIterator<HiliteSet>;\n\n /**\n * Disposes the cache.\n */\n [Symbol.dispose]: () => void;\n}\n\n/**\n * Creates a hilite set provider that can efficiently get a hilite set for the \"active\" selection in an iModel.\n *\n * This specific implementation caches the hilite set for the current selection, so subsequent hilite set\n * requests for the same iModel, don't cost until selection changes.\n *\n * @public\n */\nexport function createIModelHiliteSetProvider(props: IModelHiliteSetProviderProps): IModelHiliteSetProvider {\n return new IModelHiliteSetProviderImpl(props);\n}\n\nclass IModelHiliteSetProviderImpl implements IModelHiliteSetProvider {\n private _selectionStorage: SelectionStorage;\n private _hiliteSetProviders = new Map<string, HiliteSetProvider>();\n private _cache = new Map<string, Observable<HiliteSet>>();\n private _removeListener: () => void;\n private _imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n private _createHiliteSetProvider: typeof createHiliteSetProvider;\n\n constructor(props: IModelHiliteSetProviderProps) {\n this._selectionStorage = props.selectionStorage;\n this._imodelProvider = props.imodelProvider;\n this._removeListener = this._selectionStorage.selectionChangeEvent.addListener(\n (args: StorageSelectionChangeEventArgs) => {\n this._cache.delete(args.imodelKey);\n if (args.changeType === \"clear\" && args.source === CLEAR_SELECTION_STORAGE_SOURCE) {\n this._hiliteSetProviders.delete(args.imodelKey);\n }\n },\n );\n /* v8 ignore next -- @preserve */\n this._createHiliteSetProvider = props.createHiliteSetProvider ?? createHiliteSetProvider;\n }\n\n public getHiliteSetProvider({ imodelKey }: { imodelKey: string }): HiliteSetProvider {\n let provider = this._hiliteSetProviders.get(imodelKey);\n if (!provider) {\n provider = this._createHiliteSetProvider({ imodelAccess: this._imodelProvider(imodelKey) });\n this._hiliteSetProviders.set(imodelKey, provider);\n }\n return provider;\n }\n\n public getCurrentHiliteSet({ imodelKey }: { imodelKey: string }): AsyncIterableIterator<HiliteSet> {\n let hiliteSet = this._cache.get(imodelKey);\n if (!hiliteSet) {\n const selectables = this._selectionStorage.getSelection({ imodelKey });\n hiliteSet = from(this.getHiliteSetProvider({ imodelKey }).getHiliteSet({ selectables })).pipe(\n shareReplay({ refCount: true }),\n );\n this._cache.set(imodelKey, hiliteSet);\n }\n return eachValueFrom(hiliteSet);\n }\n\n public [Symbol.dispose](): void {\n this._removeListener();\n this._hiliteSetProviders = new Map();\n this._cache = new Map();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selectable.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Selectable.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,gBAAgB,EAAE,MAAM,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;IACrE,kDAAkD;IAClD,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG,IAAI,CAAC,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CAoB3E;IAED;;;;;OAKG;IACH,SAAgB,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAmB9E;IAED;;;;OAIG;IACH,SAAgB,KAAK,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAOvD;IAED;;;;OAIG;IACH,SAAgB,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,WAc3F;IAED;;;;OAIG;IACH,SAAgB,OAAO,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,QAQ1G;IAED;;;;OAIG;IACH,SAAgB,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAc3F;CACF"}
|
|
@@ -8,6 +8,7 @@ exports.Selectables = exports.TRANSIENT_ELEMENT_CLASSNAME = exports.Selectable =
|
|
|
8
8
|
const rxjs_1 = require("rxjs");
|
|
9
9
|
const rxjs_for_await_1 = require("rxjs-for-await");
|
|
10
10
|
const presentation_shared_1 = require("@itwin/presentation-shared");
|
|
11
|
+
const Utils_js_1 = require("./Utils.js");
|
|
11
12
|
/** @public */
|
|
12
13
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
13
14
|
var Selectable;
|
|
@@ -227,7 +228,7 @@ var Selectables;
|
|
|
227
228
|
* @public
|
|
228
229
|
*/
|
|
229
230
|
function load(selectables) {
|
|
230
|
-
return (0, rxjs_for_await_1.eachValueFrom)((0, rxjs_1.merge)((0, rxjs_1.from)(selectables.instanceKeys).pipe((0, rxjs_1.mergeMap)(([className, ids]) => (0, rxjs_1.from)(ids).pipe((0, rxjs_1.map)((id) => ({ className, id }))))), (0, rxjs_1.from)(selectables.custom).pipe((0, rxjs_1.mergeMap)(([_, selectable]) => (0, rxjs_1.from)(selectable.loadInstanceKeys())))));
|
|
231
|
+
return (0, rxjs_for_await_1.eachValueFrom)((0, rxjs_1.merge)((0, rxjs_1.from)(selectables.instanceKeys).pipe((0, rxjs_1.mergeMap)(([className, ids]) => (0, rxjs_1.from)(ids).pipe((0, Utils_js_1.releaseMainThreadOnItemsCount)(1000), (0, rxjs_1.map)((id) => ({ className, id }))))), (0, rxjs_1.from)(selectables.custom).pipe((0, rxjs_1.mergeMap)(([_, selectable]) => (0, rxjs_1.from)(selectable.loadInstanceKeys())))));
|
|
231
232
|
}
|
|
232
233
|
Selectables.load = load;
|
|
233
234
|
})(Selectables || (exports.Selectables = Selectables = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAAkD;AAClD,mDAA+C;AAE/C,oEAAoE;AAiDpE,cAAc;AACd,2DAA2D;AAC3D,IAAiB,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAA6C;QACzE,MAAM,WAAW,GAAG,UAAmC,CAAC;QACxD,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;IACrD,CAAC;IAHe,wBAAa,gBAG5B,CAAA;IAED,+DAA+D;IAC/D,SAAgB,QAAQ,CAAC,UAAsB;QAC7C,OAAO,CAAC,CAAE,UAA+B,CAAC,UAAU,CAAC;IACvD,CAAC;IAFe,mBAAQ,WAEvB,CAAA;AACH,CAAC,EAXgB,UAAU,0BAAV,UAAU,QAW1B;AAiBD;;;GAGG;AACU,QAAA,2BAA2B,GAAG,YAAY,CAAC;AAExD,cAAc;AACd,IAAiB,WAAW,CA2M3B;AA3MD,WAAiB,WAAW;IAC1B;;;;OAIG;IACH,SAAgB,MAAM,CAAC,MAAoB;QACzC,MAAM,cAAc,GAAG;YACrB,YAAY,EAAE,IAA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------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { from, map, merge, mergeMap } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\n\n/**\n * ECInstance selectable\n * @public\n */\nexport interface SelectableInstanceKey {\n /**\n * Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName` for\n * persistent instances or `TRANSIENT_ELEMENT_CLASSNAME` for transient instances.\n */\n className: string;\n\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable, which has an identifier, knows how to loads its associated selectable instance keys\n * and has custom data associated with it.\n *\n * An example of such selectable could be an instance grouping node:\n * - `identifier` could be a GUID, associated with the node,\n * - `loadInstanceKeys` would know how to load grouped instance keys from the node,\n * - `data` could be set to the node itself.\n *\n * @public\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something that can be selected in an iTwin.js application.\n * @public\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * A type of identifier that can be used to identify a selectable in selection storage.\n * @public\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @public\n */\nexport interface Selectables {\n /**\n * A map between `SelectableInstanceKey.className` and a set of selected instance IDs.\n */\n instanceKeys: Map<string, Set<Id64String>>;\n /**\n * A map between `CustomSelectable.identifier` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/**\n * Class name used to create `SelectableInstanceKey` for transient elements.\n * @public\n */\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\n\n/** @public */\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @public\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @public\n */\n export function size(selectables: Selectables): number {\n let instanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (instanceCount += set.size));\n return instanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @public\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @public\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @public\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @public\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @public\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n /**\n * Load all instance keys from the given `Selectables` object.\n * @param selectables `Selectables` object to load instance keys from\n * @public\n */\n export function load(selectables: Selectables): AsyncIterableIterator<SelectableInstanceKey> {\n return eachValueFrom(\n merge(\n from(selectables.instanceKeys).pipe(\n mergeMap(([className, ids]) => from(ids).pipe(map((id) => ({ className, id })))),\n ),\n from(selectables.custom).pipe(mergeMap(([_, selectable]) => from(selectable.loadInstanceKeys()))),\n ),\n );\n }\n}\n\nfunction normalizeClassName(fullClassName: string) {\n return fullClassName === TRANSIENT_ELEMENT_CLASSNAME ? fullClassName : normalizeFullClassName(fullClassName);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,+BAAkD;AAClD,mDAA+C;AAE/C,oEAAoE;AACpE,yCAA2D;AAiD3D,cAAc;AACd,2DAA2D;AAC3D,IAAiB,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CA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ACnC,IAAA,UAAG,EAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CACjC,CACF,CACF,EACD,IAAA,WAAI,EAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAA,eAAQ,EAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAClG,CACF,CAAC;IACJ,CAAC;IAde,gBAAI,OAcnB,CAAA;AACH,CAAC,EAhNgB,WAAW,2BAAX,WAAW,QAgN3B;AAED,SAAS,kBAAkB,CAAC,aAAqB;IAC/C,OAAO,aAAa,KAAK,mCAA2B,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAA,4CAAsB,EAAC,aAAa,CAAC,CAAC;AAC/G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { from, map, merge, mergeMap } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\nimport { releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\n/**\n * ECInstance selectable\n * @public\n */\nexport interface SelectableInstanceKey {\n /**\n * Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName` for\n * persistent instances or `TRANSIENT_ELEMENT_CLASSNAME` for transient instances.\n */\n className: string;\n\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable, which has an identifier, knows how to loads its associated selectable instance keys\n * and has custom data associated with it.\n *\n * An example of such selectable could be an instance grouping node:\n * - `identifier` could be a GUID, associated with the node,\n * - `loadInstanceKeys` would know how to load grouped instance keys from the node,\n * - `data` could be set to the node itself.\n *\n * @public\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something that can be selected in an iTwin.js application.\n * @public\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * A type of identifier that can be used to identify a selectable in selection storage.\n * @public\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @public\n */\nexport interface Selectables {\n /**\n * A map between `SelectableInstanceKey.className` and a set of selected instance IDs.\n */\n instanceKeys: Map<string, Set<Id64String>>;\n /**\n * A map between `CustomSelectable.identifier` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/**\n * Class name used to create `SelectableInstanceKey` for transient elements.\n * @public\n */\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\n\n/** @public */\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @public\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @public\n */\n export function size(selectables: Selectables): number {\n let instanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (instanceCount += set.size));\n return instanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @public\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @public\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @public\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @public\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @public\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n /**\n * Load all instance keys from the given `Selectables` object.\n * @param selectables `Selectables` object to load instance keys from\n * @public\n */\n export function load(selectables: Selectables): AsyncIterableIterator<SelectableInstanceKey> {\n return eachValueFrom(\n merge(\n from(selectables.instanceKeys).pipe(\n mergeMap(([className, ids]) =>\n from(ids).pipe(\n releaseMainThreadOnItemsCount(1000),\n map((id) => ({ className, id })),\n ),\n ),\n ),\n from(selectables.custom).pipe(mergeMap(([_, selectable]) => from(selectable.loadInstanceKeys()))),\n ),\n );\n }\n}\n\nfunction normalizeClassName(fullClassName: string) {\n return fullClassName === TRANSIENT_ELEMENT_CLASSNAME ? fullClassName : normalizeFullClassName(fullClassName);\n}\n"]}
|
|
@@ -96,7 +96,10 @@ export interface SelectionStorage {
|
|
|
96
96
|
* @public
|
|
97
97
|
*/
|
|
98
98
|
export declare function createStorage(): SelectionStorage;
|
|
99
|
-
/**
|
|
100
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The source name used when selection change is caused by clearing the selection storage. Used when change is performed by `clearStorage`.
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare const CLEAR_SELECTION_STORAGE_SOURCE = "Unified selection storage: clear";
|
|
101
104
|
export {};
|
|
102
105
|
//# sourceMappingURL=SelectionStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionStorage.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAEL,+BAA+B,EAEhC,MAAM,2BAA2B,CAAC;AAEnC,cAAc;AACd,KAAK,aAAa,GACd;IACE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GACD;IACE,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;;;;;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AI,CAAC;IAER,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED
|
|
1
|
+
{"version":3,"file":"SelectionStorage.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAEL,+BAA+B,EAEhC,MAAM,2BAA2B,CAAC;AAEnC,cAAc;AACd,KAAK,aAAa,GACd;IACE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GACD;IACE,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEN;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,oBAAoB,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAE7D,0EAA0E;IAC1E,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAAC;IAEnD,+CAA+C;IAC/C,YAAY,CACV,KAAK,EAAE,aAAa,GAAG;QACrB,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,WAAW,CAAC;IAEf,iCAAiC;IACjC,cAAc,CACZ,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,2CAA2C;QAC3C,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,0CAA0C;IAC1C,mBAAmB,CACjB,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,gDAAgD;QAChD,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,iCAAiC;IACjC,gBAAgB,CACd,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,2CAA2C;QAC3C,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,+BAA+B;IAC/B,cAAc,CACZ,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED;;;GAGG;AACH,eAAO,MAAM,8BAA8B,qCAAqC,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.CLEAR_SELECTION_STORAGE_SOURCE = void 0;
|
|
8
8
|
exports.createStorage = createStorage;
|
|
9
9
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
10
10
|
const Selectable_js_1 = require("./Selectable.js");
|
|
@@ -27,8 +27,11 @@ const Selectable_js_1 = require("./Selectable.js");
|
|
|
27
27
|
function createStorage() {
|
|
28
28
|
return new SelectionStorageImpl();
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The source name used when selection change is caused by clearing the selection storage. Used when change is performed by `clearStorage`.
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
exports.CLEAR_SELECTION_STORAGE_SOURCE = "Unified selection storage: clear";
|
|
32
35
|
class SelectionStorageImpl {
|
|
33
36
|
_storage = new Map();
|
|
34
37
|
selectionChangeEvent;
|
|
@@ -55,7 +58,7 @@ class SelectionStorageImpl {
|
|
|
55
58
|
}
|
|
56
59
|
clearStorage(props) {
|
|
57
60
|
const imodelKey = getIModelKey(props);
|
|
58
|
-
this.clearSelection({ source: exports.
|
|
61
|
+
this.clearSelection({ source: exports.CLEAR_SELECTION_STORAGE_SOURCE, imodelKey });
|
|
59
62
|
this._storage.delete(imodelKey);
|
|
60
63
|
}
|
|
61
64
|
getContainer(imodelKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA8HhG,sCAEC;AA9HD,sDAA8C;AAE9C,mDAA0D;AA0G1D;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC;AAED,gBAAgB;AACH,QAAA,mCAAmC,GAAG,kCAAkC,CAAC;AAEtF,MAAM,oBAAoB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9D,oBAAoB,CAA2C;IAEtE;QACE,IAAI,CAAC,oBAAoB,GAAG,IAAI,sBAAO,EAAE,CAAC;IAC5C,CAAC;IAEM,kBAAkB,CAAC,KAAoB;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACrE,CAAC;IAEM,YAAY,CAAC,KAAyC;Q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CAAC,CAAC,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,KAAa;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACxD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,2BAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Event } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables } from \"./Selectable.js\";\nimport {\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n StorageSelectionChangeType,\n} from \"./SelectionChangeEvent.js\";\n\n/** @public */\ntype IModelKeyProp =\n | {\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n */\n imodelKey?: string;\n iModelKey?: never;\n }\n | {\n imodelKey?: never;\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n *\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey?: string;\n };\n\n/**\n * Defines return value of `createStorage`.\n *\n * **Warning:** Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n *\n * @see `createStorage`\n * @public\n */\nexport interface SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: Event<StorageSelectionChangesListener>;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: IModelKeyProp): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(\n props: IModelKeyProp & {\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Replace current selection. */\n replaceSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear current selection. */\n clearSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: IModelKeyProp): void;\n}\n\n/**\n * Creates a selection storage which stores and allows managing application-level selection.\n *\n * **Note:** `clearSelection` should be called upon iModel close to free-up memory:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createIModelKey } from \"@itwin/presentation-core-interop\";\n *\n * IModelConnection.onClose.addListener((imodel) => {\n * storage.clearStorage(createIModelKey(imodel));\n * });\n * ```\n *\n * @public\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\n/** @internal */\nexport const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = \"Unified selection storage: clear\";\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: BeEvent<StorageSelectionChangesListener>;\n\n constructor() {\n this.selectionChangeEvent = new BeEvent();\n }\n\n public getSelectionLevels(props: IModelKeyProp): number[] {\n return this.getContainer(getIModelKey(props)).getSelectionLevels();\n }\n\n public getSelection(props: IModelKeyProp & { level?: number }): Selectables {\n return this.getContainer(getIModelKey(props)).getSelection(props.level ?? 0);\n }\n\n public addToSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(\n props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number },\n ): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: IModelKeyProp & { source: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage(props: IModelKeyProp): void {\n const imodelKey = getIModelKey(props);\n this.clearSelection({ source: IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, imodelKey });\n this._storage.delete(imodelKey);\n }\n\n private getContainer(imodelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(imodelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(imodelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(\n props: IModelKeyProp & {\n source: string;\n level?: number;\n changeType: StorageSelectionChangeType;\n selectables: Selectable[];\n },\n ) {\n const { source, level: inLevel, changeType, selectables: change } = props;\n const imodelKey = getIModelKey(props);\n const container = this.getContainer(imodelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n imodelKey,\n iModelKey: imodelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n storage: this,\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nfunction getIModelKey(props: IModelKeyProp): string {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return (\"imodelKey\" in props ? props.imodelKey : props.iModelKey) ?? \"\";\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AA8HhG,sCAEC;AA9HD,sDAA8C;AAE9C,mDAA0D;AA0G1D;;;;;;;;;;;;;;;GAeG;AACH,S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GAAG,2BAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,kBAAkB;QACvB,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1D,IAAI,CAAC,2BAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,KAAa;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACxD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,2BAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Event } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables } from \"./Selectable.js\";\nimport {\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n StorageSelectionChangeType,\n} from \"./SelectionChangeEvent.js\";\n\n/** @public */\ntype IModelKeyProp =\n | {\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n */\n imodelKey?: string;\n iModelKey?: never;\n }\n | {\n imodelKey?: never;\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n *\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey?: string;\n };\n\n/**\n * Defines return value of `createStorage`.\n *\n * **Warning:** Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n *\n * @see `createStorage`\n * @public\n */\nexport interface SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: Event<StorageSelectionChangesListener>;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: IModelKeyProp): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(\n props: IModelKeyProp & {\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Replace current selection. */\n replaceSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear current selection. */\n clearSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: IModelKeyProp): void;\n}\n\n/**\n * Creates a selection storage which stores and allows managing application-level selection.\n *\n * **Note:** `clearSelection` should be called upon iModel close to free-up memory:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createIModelKey } from \"@itwin/presentation-core-interop\";\n *\n * IModelConnection.onClose.addListener((imodel) => {\n * storage.clearStorage(createIModelKey(imodel));\n * });\n * ```\n *\n * @public\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\n/**\n * The source name used when selection change is caused by clearing the selection storage. Used when change is performed by `clearStorage`.\n * @public\n */\nexport const CLEAR_SELECTION_STORAGE_SOURCE = \"Unified selection storage: clear\";\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: BeEvent<StorageSelectionChangesListener>;\n\n constructor() {\n this.selectionChangeEvent = new BeEvent();\n }\n\n public getSelectionLevels(props: IModelKeyProp): number[] {\n return this.getContainer(getIModelKey(props)).getSelectionLevels();\n }\n\n public getSelection(props: IModelKeyProp & { level?: number }): Selectables {\n return this.getContainer(getIModelKey(props)).getSelection(props.level ?? 0);\n }\n\n public addToSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(\n props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number },\n ): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: IModelKeyProp & { source: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage(props: IModelKeyProp): void {\n const imodelKey = getIModelKey(props);\n this.clearSelection({ source: CLEAR_SELECTION_STORAGE_SOURCE, imodelKey });\n this._storage.delete(imodelKey);\n }\n\n private getContainer(imodelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(imodelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(imodelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(\n props: IModelKeyProp & {\n source: string;\n level?: number;\n changeType: StorageSelectionChangeType;\n selectables: Selectable[];\n },\n ) {\n const { source, level: inLevel, changeType, selectables: change } = props;\n const imodelKey = getIModelKey(props);\n const container = this.getContainer(imodelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n imodelKey,\n iModelKey: imodelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n storage: this,\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nfunction getIModelKey(props: IModelKeyProp): string {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return (\"imodelKey\" in props ? props.imodelKey : props.iModelKey) ?? \"\";\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
|
|
@@ -6,4 +6,5 @@ export { createIModelHiliteSetProvider, IModelHiliteSetProvider } from "./unifie
|
|
|
6
6
|
export { computeSelection, SelectionScope } from "./unified-selection/SelectionScope.js";
|
|
7
7
|
export { enableUnifiedSelectionSyncWithIModel } from "./unified-selection/EnableUnifiedSelectionSyncWithIModel.js";
|
|
8
8
|
export { StorageSelectionChangeType, StorageSelectionChangeEventArgs, StorageSelectionChangesListener, } from "./unified-selection/SelectionChangeEvent.js";
|
|
9
|
+
export { CLEAR_SELECTION_STORAGE_SOURCE } from "./unified-selection/SelectionStorage.js";
|
|
9
10
|
//# sourceMappingURL=unified-selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,GACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AACjH,OAAO,EAEL,8BAA8B,EAE9B,wBAAwB,GACzB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,6CAA6C,CAAC"}
|
|
1
|
+
{"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,GACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AACjH,OAAO,EAEL,8BAA8B,EAE9B,wBAAwB,GACzB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.enableUnifiedSelectionSyncWithIModel = exports.computeSelection = exports.createIModelHiliteSetProvider = exports.createCachingHiliteSetProvider = exports.createHiliteSetProvider = exports.createStorage = exports.Selectables = exports.Selectable = exports.TRANSIENT_ELEMENT_CLASSNAME = void 0;
|
|
7
|
+
exports.CLEAR_SELECTION_STORAGE_SOURCE = exports.enableUnifiedSelectionSyncWithIModel = exports.computeSelection = exports.createIModelHiliteSetProvider = exports.createCachingHiliteSetProvider = exports.createHiliteSetProvider = exports.createStorage = exports.Selectables = exports.Selectable = exports.TRANSIENT_ELEMENT_CLASSNAME = void 0;
|
|
8
8
|
var Selectable_js_1 = require("./unified-selection/Selectable.js");
|
|
9
9
|
Object.defineProperty(exports, "TRANSIENT_ELEMENT_CLASSNAME", { enumerable: true, get: function () { return Selectable_js_1.TRANSIENT_ELEMENT_CLASSNAME; } });
|
|
10
10
|
Object.defineProperty(exports, "Selectable", { enumerable: true, get: function () { return Selectable_js_1.Selectable; } });
|
|
@@ -22,4 +22,6 @@ var SelectionScope_js_1 = require("./unified-selection/SelectionScope.js");
|
|
|
22
22
|
Object.defineProperty(exports, "computeSelection", { enumerable: true, get: function () { return SelectionScope_js_1.computeSelection; } });
|
|
23
23
|
var EnableUnifiedSelectionSyncWithIModel_js_1 = require("./unified-selection/EnableUnifiedSelectionSyncWithIModel.js");
|
|
24
24
|
Object.defineProperty(exports, "enableUnifiedSelectionSyncWithIModel", { enumerable: true, get: function () { return EnableUnifiedSelectionSyncWithIModel_js_1.enableUnifiedSelectionSyncWithIModel; } });
|
|
25
|
+
var SelectionStorage_js_2 = require("./unified-selection/SelectionStorage.js");
|
|
26
|
+
Object.defineProperty(exports, "CLEAR_SELECTION_STORAGE_SOURCE", { enumerable: true, get: function () { return SelectionStorage_js_2.CLEAR_SELECTION_STORAGE_SOURCE; } });
|
|
25
27
|
//# sourceMappingURL=unified-selection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,mEAO2C;AANzC,4HAAA,2BAA2B,OAAA;AAE3B,2GAAA,UAAU,OAAA;AAGV,4GAAA,WAAW,OAAA;AAEb,+EAA0F;AAA/D,oHAAA,aAAa,OAAA;AACxC,iFAAiH;AAAxG,+HAAA,uBAAuB,OAAA;AAChC,+FAKyD;AAJvD,4DAA4D;AAC5D,6IAAA,8BAA8B,OAAA;AAIhC,6FAAwH;AAA/G,2IAAA,6BAA6B,OAAA;AACtC,2EAAyF;AAAhF,qHAAA,gBAAgB,OAAA;AACzB,uHAAmH;AAA1G,+JAAA,oCAAoC,OAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport {\n TRANSIENT_ELEMENT_CLASSNAME,\n CustomSelectable,\n Selectable,\n SelectableIdentifier,\n SelectableInstanceKey,\n Selectables,\n} from \"./unified-selection/Selectable.js\";\nexport { SelectionStorage, createStorage } from \"./unified-selection/SelectionStorage.js\";\nexport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n createCachingHiliteSetProvider,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n CachingHiliteSetProvider,\n} from \"./unified-selection/CachingHiliteSetProvider.js\";\nexport { createIModelHiliteSetProvider, IModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport { computeSelection, SelectionScope } from \"./unified-selection/SelectionScope.js\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel.js\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n} from \"./unified-selection/SelectionChangeEvent.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;AAEhG,mEAO2C;AANzC,4HAAA,2BAA2B,OAAA;AAE3B,2GAAA,UAAU,OAAA;AAGV,4GAAA,WAAW,OAAA;AAEb,+EAA0F;AAA/D,oHAAA,aAAa,OAAA;AACxC,iFAAiH;AAAxG,+HAAA,uBAAuB,OAAA;AAChC,+FAKyD;AAJvD,4DAA4D;AAC5D,6IAAA,8BAA8B,OAAA;AAIhC,6FAAwH;AAA/G,2IAAA,6BAA6B,OAAA;AACtC,2EAAyF;AAAhF,qHAAA,gBAAgB,OAAA;AACzB,uHAAmH;AAA1G,+JAAA,oCAAoC,OAAA;AAM7C,+EAAyF;AAAhF,qIAAA,8BAA8B,OAAA","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport {\n TRANSIENT_ELEMENT_CLASSNAME,\n CustomSelectable,\n Selectable,\n SelectableIdentifier,\n SelectableInstanceKey,\n Selectables,\n} from \"./unified-selection/Selectable.js\";\nexport { SelectionStorage, createStorage } from \"./unified-selection/SelectionStorage.js\";\nexport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n createCachingHiliteSetProvider,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n CachingHiliteSetProvider,\n} from \"./unified-selection/CachingHiliteSetProvider.js\";\nexport { createIModelHiliteSetProvider, IModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport { computeSelection, SelectionScope } from \"./unified-selection/SelectionScope.js\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel.js\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n} from \"./unified-selection/SelectionChangeEvent.js\";\nexport { CLEAR_SELECTION_STORAGE_SOURCE } from \"./unified-selection/SelectionStorage.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,
|
|
1
|
+
{"version":3,"file":"IModelHiliteSetProvider.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":"AAKA,OAAO,sBAAsB,CAAC;AAI9B,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAkC,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzF;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IAC3C,8DAA8D;IAC9D,gBAAgB,EAAE,gBAAgB,CAAC;IAEnC,iEAAiE;IACjE,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,GAAG,kBAAkB,CAAC;IAEtF,yHAAyH;IACzH,uBAAuB,CAAC,EAAE,OAAO,uBAAuB,CAAC;CAC1D;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,uBAAuB;IACtC,4DAA4D;IAC5D,oBAAoB,CAAC,KAAK,EAAE;QAC1B,4CAA4C;QAC5C,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,iBAAiB,CAAC;IAEtB,gFAAgF;IAChF,mBAAmB,CAAC,KAAK,EAAE;QACzB,mCAAmC;QACnC,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAErC;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,4BAA4B,GAAG,uBAAuB,CAE1G"}
|
|
@@ -6,7 +6,7 @@ import "./DisposePolyfill.js";
|
|
|
6
6
|
import { from, shareReplay } from "rxjs";
|
|
7
7
|
import { eachValueFrom } from "rxjs-for-await";
|
|
8
8
|
import { createHiliteSetProvider } from "./HiliteSetProvider.js";
|
|
9
|
-
import {
|
|
9
|
+
import { CLEAR_SELECTION_STORAGE_SOURCE } from "./SelectionStorage.js";
|
|
10
10
|
/**
|
|
11
11
|
* Creates a hilite set provider that can efficiently get a hilite set for the "active" selection in an iModel.
|
|
12
12
|
*
|
|
@@ -30,7 +30,7 @@ class IModelHiliteSetProviderImpl {
|
|
|
30
30
|
this._imodelProvider = props.imodelProvider;
|
|
31
31
|
this._removeListener = this._selectionStorage.selectionChangeEvent.addListener((args) => {
|
|
32
32
|
this._cache.delete(args.imodelKey);
|
|
33
|
-
if (args.changeType === "clear" && args.source ===
|
|
33
|
+
if (args.changeType === "clear" && args.source === CLEAR_SELECTION_STORAGE_SOURCE) {
|
|
34
34
|
this._hiliteSetProviders.delete(args.imodelKey);
|
|
35
35
|
}
|
|
36
36
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,IAAI,EAAc,WAAW,EAAE,MAAM,MAAM,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAgC,MAAM,wBAAwB,CAAC;AAE/F,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"IModelHiliteSetProvider.js","sourceRoot":"","sources":["../../../src/unified-selection/IModelHiliteSetProvider.ts"],"names":[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AAE,SAAS,EAAyB;QAC9D,IAAI,QAAQ,GAAG,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,IAAI,CAAC,wBAAwB,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YAC5F,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,mBAAmB,CAAC,EAAE,SAAS,EAAyB;QAC7D,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;YACvE,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAC3F,WAAW,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAChC,CAAC;YACF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IAEM,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport \"./DisposePolyfill.js\";\n\nimport { from, Observable, shareReplay } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { ECClassHierarchyInspector, ECSqlQueryExecutor } from \"@itwin/presentation-shared\";\nimport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./HiliteSetProvider.js\";\nimport { StorageSelectionChangeEventArgs } from \"./SelectionChangeEvent.js\";\nimport { CLEAR_SELECTION_STORAGE_SOURCE, SelectionStorage } from \"./SelectionStorage.js\";\n\n/**\n * Props for creating an `IModelHiliteSetProvider` instance.\n * @public\n */\nexport interface IModelHiliteSetProviderProps {\n /** Selection storage to use for retrieving the hilite set. */\n selectionStorage: SelectionStorage;\n\n /** A callback that should return iModel access by iModel key. */\n imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n\n /** An optional hilite set provider factory. If not provided, defaults to `createHiliteSetProvider` from this package. */\n createHiliteSetProvider?: typeof createHiliteSetProvider;\n}\n\n/**\n * Defines return value of `createIModelHiliteSetProvider`.\n *\n * **Warning:** Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n *\n * @see `createIModelHiliteSetProvider`\n * @public\n */\nexport interface IModelHiliteSetProvider {\n /** Get the hilite set provider for the specified iModel. */\n getHiliteSetProvider(props: {\n /** iModel to get hilite set provider for */\n imodelKey: string;\n }): HiliteSetProvider;\n\n /** Get the hilite set iterator for active selection in the specified iModel. */\n getCurrentHiliteSet(props: {\n /** iModel to get hilite set for */\n imodelKey: string;\n }): AsyncIterableIterator<HiliteSet>;\n\n /**\n * Disposes the cache.\n */\n [Symbol.dispose]: () => void;\n}\n\n/**\n * Creates a hilite set provider that can efficiently get a hilite set for the \"active\" selection in an iModel.\n *\n * This specific implementation caches the hilite set for the current selection, so subsequent hilite set\n * requests for the same iModel, don't cost until selection changes.\n *\n * @public\n */\nexport function createIModelHiliteSetProvider(props: IModelHiliteSetProviderProps): IModelHiliteSetProvider {\n return new IModelHiliteSetProviderImpl(props);\n}\n\nclass IModelHiliteSetProviderImpl implements IModelHiliteSetProvider {\n private _selectionStorage: SelectionStorage;\n private _hiliteSetProviders = new Map<string, HiliteSetProvider>();\n private _cache = new Map<string, Observable<HiliteSet>>();\n private _removeListener: () => void;\n private _imodelProvider: (imodelKey: string) => ECClassHierarchyInspector & ECSqlQueryExecutor;\n private _createHiliteSetProvider: typeof createHiliteSetProvider;\n\n constructor(props: IModelHiliteSetProviderProps) {\n this._selectionStorage = props.selectionStorage;\n this._imodelProvider = props.imodelProvider;\n this._removeListener = this._selectionStorage.selectionChangeEvent.addListener(\n (args: StorageSelectionChangeEventArgs) => {\n this._cache.delete(args.imodelKey);\n if (args.changeType === \"clear\" && args.source === CLEAR_SELECTION_STORAGE_SOURCE) {\n this._hiliteSetProviders.delete(args.imodelKey);\n }\n },\n );\n /* v8 ignore next -- @preserve */\n this._createHiliteSetProvider = props.createHiliteSetProvider ?? createHiliteSetProvider;\n }\n\n public getHiliteSetProvider({ imodelKey }: { imodelKey: string }): HiliteSetProvider {\n let provider = this._hiliteSetProviders.get(imodelKey);\n if (!provider) {\n provider = this._createHiliteSetProvider({ imodelAccess: this._imodelProvider(imodelKey) });\n this._hiliteSetProviders.set(imodelKey, provider);\n }\n return provider;\n }\n\n public getCurrentHiliteSet({ imodelKey }: { imodelKey: string }): AsyncIterableIterator<HiliteSet> {\n let hiliteSet = this._cache.get(imodelKey);\n if (!hiliteSet) {\n const selectables = this._selectionStorage.getSelection({ imodelKey });\n hiliteSet = from(this.getHiliteSetProvider({ imodelKey }).getHiliteSet({ selectables })).pipe(\n shareReplay({ refCount: true }),\n );\n this._cache.set(imodelKey, hiliteSet);\n }\n return eachValueFrom(hiliteSet);\n }\n\n public [Symbol.dispose](): void {\n this._removeListener();\n this._hiliteSetProviders = new Map();\n this._cache = new Map();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selectable.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"Selectable.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIjD;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,gBAAgB,EAAE,MAAM,qBAAqB,CAAC,qBAAqB,CAAC,CAAC;IACrE,kDAAkD;IAClD,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,qBAAqB,GAAG,gBAAgB,CAAC;AAElE;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,GAAG,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAEhG,cAAc;AAEd,yBAAiB,UAAU,CAAC;IAC1B,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,oBAAoB,GAAG,UAAU,IAAI,qBAAqB,CAGhH;IAED,+DAA+D;IAC/D,SAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,gBAAgB,CAE/E;CACF;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;IAC3C;;OAEG;IACH,MAAM,EAAE,GAAG,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IAAI,QAQ1G;IAED;;;;OAIG;IACH,SAAgB,IAAI,CAAC,WAAW,EAAE,WAAW,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,CAc3F;CACF"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { from, map, merge, mergeMap } from "rxjs";
|
|
6
6
|
import { eachValueFrom } from "rxjs-for-await";
|
|
7
7
|
import { normalizeFullClassName } from "@itwin/presentation-shared";
|
|
8
|
+
import { releaseMainThreadOnItemsCount } from "./Utils.js";
|
|
8
9
|
/** @public */
|
|
9
10
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
10
11
|
export var Selectable;
|
|
@@ -224,7 +225,7 @@ export var Selectables;
|
|
|
224
225
|
* @public
|
|
225
226
|
*/
|
|
226
227
|
function load(selectables) {
|
|
227
|
-
return eachValueFrom(merge(from(selectables.instanceKeys).pipe(mergeMap(([className, ids]) => from(ids).pipe(map((id) => ({ className, id }))))), from(selectables.custom).pipe(mergeMap(([_, selectable]) => from(selectable.loadInstanceKeys())))));
|
|
228
|
+
return eachValueFrom(merge(from(selectables.instanceKeys).pipe(mergeMap(([className, ids]) => from(ids).pipe(releaseMainThreadOnItemsCount(1000), map((id) => ({ className, id }))))), from(selectables.custom).pipe(mergeMap(([_, selectable]) => from(selectable.loadInstanceKeys())))));
|
|
228
229
|
}
|
|
229
230
|
Selectables.load = load;
|
|
230
231
|
})(Selectables || (Selectables = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAiDpE,cAAc;AACd,2DAA2D;AAC3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AC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CACjF,EACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAClG,CACF,CAAC;IACJ,CAAC;IATe,gBAAI,OASnB,CAAA;AACH,CAAC,EA3MgB,WAAW,KAAX,WAAW,QA2M3B;AAED,SAAS,kBAAkB,CAAC,aAAqB;IAC/C,OAAO,aAAa,KAAK,2BAA2B,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAC/G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { from, map, merge, mergeMap } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\n\n/**\n * ECInstance selectable\n * @public\n */\nexport interface SelectableInstanceKey {\n /**\n * Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName` for\n * persistent instances or `TRANSIENT_ELEMENT_CLASSNAME` for transient instances.\n */\n className: string;\n\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable, which has an identifier, knows how to loads its associated selectable instance keys\n * and has custom data associated with it.\n *\n * An example of such selectable could be an instance grouping node:\n * - `identifier` could be a GUID, associated with the node,\n * - `loadInstanceKeys` would know how to load grouped instance keys from the node,\n * - `data` could be set to the node itself.\n *\n * @public\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something that can be selected in an iTwin.js application.\n * @public\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * A type of identifier that can be used to identify a selectable in selection storage.\n * @public\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @public\n */\nexport interface Selectables {\n /**\n * A map between `SelectableInstanceKey.className` and a set of selected instance IDs.\n */\n instanceKeys: Map<string, Set<Id64String>>;\n /**\n * A map between `CustomSelectable.identifier` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/**\n * Class name used to create `SelectableInstanceKey` for transient elements.\n * @public\n */\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\n\n/** @public */\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @public\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @public\n */\n export function size(selectables: Selectables): number {\n let instanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (instanceCount += set.size));\n return instanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @public\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @public\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @public\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @public\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @public\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n /**\n * Load all instance keys from the given `Selectables` object.\n * @param selectables `Selectables` object to load instance keys from\n * @public\n */\n export function load(selectables: Selectables): AsyncIterableIterator<SelectableInstanceKey> {\n return eachValueFrom(\n merge(\n from(selectables.instanceKeys).pipe(\n mergeMap(([className, ids]) => from(ids).pipe(map((id) => ({ className, id })))),\n ),\n from(selectables.custom).pipe(mergeMap(([_, selectable]) => from(selectable.loadInstanceKeys()))),\n ),\n );\n }\n}\n\nfunction normalizeClassName(fullClassName: string) {\n return fullClassName === TRANSIENT_ELEMENT_CLASSNAME ? fullClassName : normalizeFullClassName(fullClassName);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Selectable.js","sourceRoot":"","sources":["../../../src/unified-selection/Selectable.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAiD3D,cAAc;AACd,2DAA2D;AAC3D,MAAM,KAAW,UAAU,CAW1B;AAXD,WAAiB,UAAU;IACzB,oEAAoE;IACpE,SAAgB,aAAa,CAAC,UAA6C;QACzE,MAAM,WAAW,GAAG,UAAmC,CAAC;QACxD,OAAO,CAAC,CAAC,WAAW,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC;IACrD,CAAC;IAHe,wBAAa,gBAG5B,CAAA;IAED,+DAA+D;IAC/D,SAAgB,QAAQ,CAAC,UAAsB;QAC7C,OAAO,CAAC,CAAE,UAA+B,CAAC,UAAU,CAAC;IACvD,CAAC;IAFe,mBAAQ,WAEvB,CAAA;AACH,CAAC,EAXgB,UAAU,KAAV,UAAU,QAW1B;AAiBD;;;GAGG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,YAAY,CAAC;AAExD,cAAc;AACd,MAAM,KAAW,WAA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AAC,aAAa,CAAC,CAAC,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAC/G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { from, map, merge, mergeMap } from \"rxjs\";\nimport { eachValueFrom } from \"rxjs-for-await\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { normalizeFullClassName } from \"@itwin/presentation-shared\";\nimport { releaseMainThreadOnItemsCount } from \"./Utils.js\";\n\n/**\n * ECInstance selectable\n * @public\n */\nexport interface SelectableInstanceKey {\n /**\n * Full class name in format `SchemaName:ClassName` or `SchemaName.ClassName` for\n * persistent instances or `TRANSIENT_ELEMENT_CLASSNAME` for transient instances.\n */\n className: string;\n\n /** ECInstance ID */\n id: string;\n}\n\n/**\n * A custom selectable, which has an identifier, knows how to loads its associated selectable instance keys\n * and has custom data associated with it.\n *\n * An example of such selectable could be an instance grouping node:\n * - `identifier` could be a GUID, associated with the node,\n * - `loadInstanceKeys` would know how to load grouped instance keys from the node,\n * - `data` could be set to the node itself.\n *\n * @public\n */\nexport interface CustomSelectable {\n /** Unique identifier of the selectable. */\n identifier: string;\n /** Asynchronous function for loading instance keys associated with this selectable. */\n loadInstanceKeys: () => AsyncIterableIterator<SelectableInstanceKey>;\n /** Custom data associated with the selectable. */\n data: unknown;\n}\n\n/**\n * A single selectable that identifies something that can be selected in an iTwin.js application.\n * @public\n */\nexport type Selectable = SelectableInstanceKey | CustomSelectable;\n\n/**\n * A type of identifier that can be used to identify a selectable in selection storage.\n * @public\n */\nexport type SelectableIdentifier = SelectableInstanceKey | Pick<CustomSelectable, \"identifier\">;\n\n/** @public */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport namespace Selectable {\n /** Check if the supplied selectable is a `SelectableInstanceKey` */\n export function isInstanceKey(selectable: Selectable | SelectableIdentifier): selectable is SelectableInstanceKey {\n const instanceKey = selectable as SelectableInstanceKey;\n return !!instanceKey.className && !!instanceKey.id;\n }\n\n /** Check if the supplied selectable is a `CustomSelectable` */\n export function isCustom(selectable: Selectable): selectable is CustomSelectable {\n return !!(selectable as CustomSelectable).identifier;\n }\n}\n\n/**\n * A collection of selectables that identify something that can be selected in an iTwin.js application\n * @public\n */\nexport interface Selectables {\n /**\n * A map between `SelectableInstanceKey.className` and a set of selected instance IDs.\n */\n instanceKeys: Map<string, Set<Id64String>>;\n /**\n * A map between `CustomSelectable.identifier` and the selectable itself.\n */\n custom: Map<string, CustomSelectable>;\n}\n\n/**\n * Class name used to create `SelectableInstanceKey` for transient elements.\n * @public\n */\nexport const TRANSIENT_ELEMENT_CLASSNAME = \"/TRANSIENT\";\n\n/** @public */\nexport namespace Selectables {\n /**\n * Creates `Selectables` from array of selectable\n * @param source Source to create selectables from\n * @public\n */\n export function create(source: Selectable[]): Selectables {\n const newSelectables = {\n instanceKeys: new Map<string, Set<string>>(),\n custom: new Map<string, CustomSelectable>(),\n };\n Selectables.add(newSelectables, source);\n return newSelectables;\n }\n\n /**\n * Get the number of selectables stored in a `Selectables` object.\n * @param selectables `Selectables` object to get size for\n * @public\n */\n export function size(selectables: Selectables): number {\n let instanceCount = 0;\n selectables.instanceKeys.forEach((set: Set<string>) => (instanceCount += set.size));\n return instanceCount + selectables.custom.size;\n }\n\n /**\n * Is a `Selectables` object currently empty.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function isEmpty(selectables: Selectables): boolean {\n return Selectables.size(selectables) === 0;\n }\n\n /**\n * Check if a `Selectables` object contains the specified selectable.\n * @param selectables `Selectables` object to check\n * @param value The selectable to check for.\n * @public\n */\n export function has(selectables: Selectables, value: SelectableIdentifier): boolean {\n if (Selectable.isInstanceKey(value)) {\n const normalizedClassName = normalizeClassName(value.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n return !!(set && set.has(value.id));\n }\n return selectables.custom.has(value.identifier);\n }\n\n /**\n * Check if a `Selectables` object contains all the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAll(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n if (Selectables.size(selectables) < values.length) {\n return false;\n }\n for (const selectable of values) {\n if (!Selectables.has(selectables, selectable)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if a `Selectables` object contains any of the specified selectables.\n * @param selectables `Selectables` object to check\n * @param values The selectables to check for.\n * @public\n */\n export function hasAny(selectables: Selectables, values: SelectableIdentifier[]): boolean {\n for (const selectable of values) {\n if (Selectables.has(selectables, selectable)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Add a one or more selectables to a `Selectables`\n * @param selectables `Selectables` object to add selectables for\n * @param values Selectables to add.\n * @public\n */\n export function add(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n let set = selectables.instanceKeys.get(normalizedClassName);\n if (!set) {\n set = new Set<string>();\n }\n if (!set.has(selectable.id)) {\n set.add(selectable.id);\n selectables.instanceKeys.set(normalizedClassName, set);\n hasChanged = true;\n }\n } else if (!selectables.custom.has(selectable.identifier)) {\n selectables.custom.set(selectable.identifier, selectable);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Removes one or more selectables from a `Selectables` object.\n * @param selectables `Selectables` object to remove selectables for\n * @param values Selectables to remove.\n * @public\n */\n export function remove(selectables: Selectables, values: Selectable[]): boolean {\n let hasChanged = false;\n for (const selectable of values) {\n if (Selectable.isInstanceKey(selectable)) {\n const normalizedClassName = normalizeClassName(selectable.className);\n const set = selectables.instanceKeys.get(normalizedClassName);\n if (set && set.has(selectable.id)) {\n set.delete(selectable.id);\n hasChanged = true;\n if (set.size === 0) {\n selectables.instanceKeys.delete(normalizedClassName);\n }\n }\n } else if (selectables.custom.has(selectable.identifier)) {\n selectables.custom.delete(selectable.identifier);\n hasChanged = true;\n }\n }\n return hasChanged;\n }\n\n /**\n * Clear a `Selectables` object.\n * @param selectables `Selectables` object to clear selectables for\n * @public\n */\n export function clear(selectables: Selectables): boolean {\n if (Selectables.size(selectables) === 0) {\n return false;\n }\n selectables.instanceKeys = new Map<string, Set<string>>();\n selectables.custom = new Map<string, CustomSelectable>();\n return true;\n }\n\n /**\n * Check whether at least one selectable passes a condition in a `Selectables` object.\n * @param selectables `Selectables` object to check\n * @public\n */\n export function some(selectables: Selectables, callback: (selectable: Selectable) => boolean) {\n for (const entry of selectables.instanceKeys) {\n for (const item of entry[1]) {\n if (callback({ className: entry[0], id: item })) {\n return true;\n }\n }\n }\n for (const entry of selectables.custom) {\n if (callback(entry[1])) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Iterate over all keys in a `Selectables` object.\n * @param selectables `Selectables` object to iterate over\n * @public\n */\n export function forEach(selectables: Selectables, callback: (selectable: Selectable, index: number) => void) {\n let index = 0;\n selectables.instanceKeys.forEach((ids: Set<string>, className: string) => {\n ids.forEach((id: string) => callback({ className, id }, index++));\n });\n selectables.custom.forEach((data) => {\n callback(data, index++);\n });\n }\n\n /**\n * Load all instance keys from the given `Selectables` object.\n * @param selectables `Selectables` object to load instance keys from\n * @public\n */\n export function load(selectables: Selectables): AsyncIterableIterator<SelectableInstanceKey> {\n return eachValueFrom(\n merge(\n from(selectables.instanceKeys).pipe(\n mergeMap(([className, ids]) =>\n from(ids).pipe(\n releaseMainThreadOnItemsCount(1000),\n map((id) => ({ className, id })),\n ),\n ),\n ),\n from(selectables.custom).pipe(mergeMap(([_, selectable]) => from(selectable.loadInstanceKeys()))),\n ),\n );\n }\n}\n\nfunction normalizeClassName(fullClassName: string) {\n return fullClassName === TRANSIENT_ELEMENT_CLASSNAME ? fullClassName : normalizeFullClassName(fullClassName);\n}\n"]}
|
|
@@ -96,7 +96,10 @@ export interface SelectionStorage {
|
|
|
96
96
|
* @public
|
|
97
97
|
*/
|
|
98
98
|
export declare function createStorage(): SelectionStorage;
|
|
99
|
-
/**
|
|
100
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The source name used when selection change is caused by clearing the selection storage. Used when change is performed by `clearStorage`.
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare const CLEAR_SELECTION_STORAGE_SOURCE = "Unified selection storage: clear";
|
|
101
104
|
export {};
|
|
102
105
|
//# sourceMappingURL=SelectionStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionStorage.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAEL,+BAA+B,EAEhC,MAAM,2BAA2B,CAAC;AAEnC,cAAc;AACd,KAAK,aAAa,GACd;IACE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,GACD;IACE,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEN;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,oBAAoB,EAAE,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAE7D,0EAA0E;IAC1E,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAAC;IAEnD,+CAA+C;IAC/C,YAAY,CACV,KAAK,EAAE,aAAa,GAAG;QACrB,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,WAAW,CAAC;IAEf,iCAAiC;IACjC,cAAc,CACZ,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,2CAA2C;QAC3C,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,0CAA0C;IAC1C,mBAAmB,CACjB,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,gDAAgD;QAChD,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,iCAAiC;IACjC,gBAAgB,CACd,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,2CAA2C;QAC3C,WAAW,EAAE,UAAU,EAAE,CAAC;QAC1B,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,+BAA+B;IAC/B,cAAc,CACZ,KAAK,EAAE,aAAa,GAAG;QACrB,8GAA8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED
|
|
1
|
+
{"version":3,"file":"SelectionStorage.d.ts","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAEL,+BAA+B,EAEhC,MAAM,2BAA2B,CAAC;AAEnC,cAAc;AACd,KAAK,aAAa,GACd;IACE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CA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8G;QAC9G,MAAM,EAAE,MAAM,CAAC;QACf,+CAA+C;QAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,IAAI,CAAC;IAER,yFAAyF;IACzF,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,IAAI,gBAAgB,CAEhD;AAED;;;GAGG;AACH,eAAO,MAAM,8BAA8B,qCAAqC,CAAC"}
|
|
@@ -23,8 +23,11 @@ import { Selectables } from "./Selectable.js";
|
|
|
23
23
|
export function createStorage() {
|
|
24
24
|
return new SelectionStorageImpl();
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* The source name used when selection change is caused by clearing the selection storage. Used when change is performed by `clearStorage`.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export const CLEAR_SELECTION_STORAGE_SOURCE = "Unified selection storage: clear";
|
|
28
31
|
class SelectionStorageImpl {
|
|
29
32
|
_storage = new Map();
|
|
30
33
|
selectionChangeEvent;
|
|
@@ -51,7 +54,7 @@ class SelectionStorageImpl {
|
|
|
51
54
|
}
|
|
52
55
|
clearStorage(props) {
|
|
53
56
|
const imodelKey = getIModelKey(props);
|
|
54
|
-
this.clearSelection({ source:
|
|
57
|
+
this.clearSelection({ source: CLEAR_SELECTION_STORAGE_SOURCE, imodelKey });
|
|
55
58
|
this._storage.delete(imodelKey);
|
|
56
59
|
}
|
|
57
60
|
getContainer(imodelKey) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAc,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA0G1D;;;;;;;;;;;;;;;GAeG;A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jB,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YACrC,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAEM,kBAAkB;QACvB,MAAM,MAAM,GAAG,IAAI,KAAK,EAAU,CAAC;QACnC,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1D,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACxB,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,KAAa;QACxB,MAAM,YAAY,GAAG,IAAI,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC;QACxD,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,IAAI,WAAW,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Event } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables } from \"./Selectable.js\";\nimport {\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n StorageSelectionChangeType,\n} from \"./SelectionChangeEvent.js\";\n\n/** @public */\ntype IModelKeyProp =\n | {\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n */\n imodelKey?: string;\n iModelKey?: never;\n }\n | {\n imodelKey?: never;\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n *\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey?: string;\n };\n\n/**\n * Defines return value of `createStorage`.\n *\n * **Warning:** Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n *\n * @see `createStorage`\n * @public\n */\nexport interface SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: Event<StorageSelectionChangesListener>;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: IModelKeyProp): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(\n props: IModelKeyProp & {\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Replace current selection. */\n replaceSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear current selection. */\n clearSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: IModelKeyProp): void;\n}\n\n/**\n * Creates a selection storage which stores and allows managing application-level selection.\n *\n * **Note:** `clearSelection` should be called upon iModel close to free-up memory:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createIModelKey } from \"@itwin/presentation-core-interop\";\n *\n * IModelConnection.onClose.addListener((imodel) => {\n * storage.clearStorage(createIModelKey(imodel));\n * });\n * ```\n *\n * @public\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\n/** @internal */\nexport const IMODEL_CLOSE_SELECTION_CLEAR_SOURCE = \"Unified selection storage: clear\";\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: BeEvent<StorageSelectionChangesListener>;\n\n constructor() {\n this.selectionChangeEvent = new BeEvent();\n }\n\n public getSelectionLevels(props: IModelKeyProp): number[] {\n return this.getContainer(getIModelKey(props)).getSelectionLevels();\n }\n\n public getSelection(props: IModelKeyProp & { level?: number }): Selectables {\n return this.getContainer(getIModelKey(props)).getSelection(props.level ?? 0);\n }\n\n public addToSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(\n props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number },\n ): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: IModelKeyProp & { source: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage(props: IModelKeyProp): void {\n const imodelKey = getIModelKey(props);\n this.clearSelection({ source: IMODEL_CLOSE_SELECTION_CLEAR_SOURCE, imodelKey });\n this._storage.delete(imodelKey);\n }\n\n private getContainer(imodelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(imodelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(imodelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(\n props: IModelKeyProp & {\n source: string;\n level?: number;\n changeType: StorageSelectionChangeType;\n selectables: Selectable[];\n },\n ) {\n const { source, level: inLevel, changeType, selectables: change } = props;\n const imodelKey = getIModelKey(props);\n const container = this.getContainer(imodelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n imodelKey,\n iModelKey: imodelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n storage: this,\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nfunction getIModelKey(props: IModelKeyProp): string {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return (\"imodelKey\" in props ? props.imodelKey : props.iModelKey) ?? \"\";\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SelectionStorage.js","sourceRoot":"","sources":["../../../src/unified-selection/SelectionStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAc,WAAW,EAAE,MAAM,iBAAiB,CAAC;AA0G1D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,oBAAoB,EAAE,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,kCAAkC,CAAC;AAEjF,MAAM,oBAAoB;IAChB,QAAQ,GAAG,IAAI,GAAG,EAA0C,CAAC;IAC9D,oBAAoB,CAA2C;IAEtE;QACE,IAAI,CAAC,oBAAoB,GAAG,IAAI,OAAO,EAAE,CAAC;IAC5C,CAAC;IAEM,kBAAkB,CAAC,KAAoB;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC;IACrE,CAAC;IAEM,YAAY,CAAC,KAAyC;QAC3D,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAC/E,CAAC;IAEM,cAAc,CAAC,KAAoF;QACxG,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IA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;gBACzB,MAAM,WAAW,GAAG,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;gBAClE,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { BeEvent } from \"@itwin/core-bentley\";\nimport { Event } from \"@itwin/presentation-shared\";\nimport { Selectable, Selectables } from \"./Selectable.js\";\nimport {\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n StorageSelectionChangeType,\n} from \"./SelectionChangeEvent.js\";\n\n/** @public */\ntype IModelKeyProp =\n | {\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n */\n imodelKey?: string;\n iModelKey?: never;\n }\n | {\n imodelKey?: never;\n /**\n * Key of the iModel. It's recommended to use `createIModelKey` function from `@itwin/presentation-core-interop`\n * package to create the key for an iModel.\n *\n * Defaults to an empty string when not supplied.\n *\n * @deprecated in 0.2. Use `imodelKey` instead.\n */\n iModelKey?: string;\n };\n\n/**\n * Defines return value of `createStorage`.\n *\n * **Warning:** Used in public API as a return value. Not expected to be created / extended by package\n * consumers, may be supplemented with required attributes any time.\n *\n * @see `createStorage`\n * @public\n */\nexport interface SelectionStorage {\n /** An event that is raised when selection changes. */\n selectionChangeEvent: Event<StorageSelectionChangesListener>;\n\n /** Get the selection levels currently stored for the specified iModel. */\n getSelectionLevels(props: IModelKeyProp): number[];\n\n /** Get the selection stored in the storage. */\n getSelection(\n props: IModelKeyProp & {\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): Selectables;\n\n /** Add keys to the selection. */\n addToSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Remove keys from current selection. */\n removeFromSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to remove from selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Replace current selection. */\n replaceSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** The selectables to add to selection. */\n selectables: Selectable[];\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear current selection. */\n clearSelection(\n props: IModelKeyProp & {\n /** Name of the selection source. Generally, this identifies the component that makes the selection change. */\n source: string;\n /** Level of the selection. Defaults to `0`. */\n level?: number;\n },\n ): void;\n\n /** Clear storage for an iModel. This function should be called when iModel is closed. */\n clearStorage(props: IModelKeyProp): void;\n}\n\n/**\n * Creates a selection storage which stores and allows managing application-level selection.\n *\n * **Note:** `clearSelection` should be called upon iModel close to free-up memory:\n *\n * ```ts\n * import { IModelConnection } from \"@itwin/core-frontend\";\n * import { createIModelKey } from \"@itwin/presentation-core-interop\";\n *\n * IModelConnection.onClose.addListener((imodel) => {\n * storage.clearStorage(createIModelKey(imodel));\n * });\n * ```\n *\n * @public\n */\nexport function createStorage(): SelectionStorage {\n return new SelectionStorageImpl();\n}\n\n/**\n * The source name used when selection change is caused by clearing the selection storage. Used when change is performed by `clearStorage`.\n * @public\n */\nexport const CLEAR_SELECTION_STORAGE_SOURCE = \"Unified selection storage: clear\";\n\nclass SelectionStorageImpl implements SelectionStorage {\n private _storage = new Map<string, MultiLevelSelectablesContainer>();\n public selectionChangeEvent: BeEvent<StorageSelectionChangesListener>;\n\n constructor() {\n this.selectionChangeEvent = new BeEvent();\n }\n\n public getSelectionLevels(props: IModelKeyProp): number[] {\n return this.getContainer(getIModelKey(props)).getSelectionLevels();\n }\n\n public getSelection(props: IModelKeyProp & { level?: number }): Selectables {\n return this.getContainer(getIModelKey(props)).getSelection(props.level ?? 0);\n }\n\n public addToSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"add\" });\n }\n\n public removeFromSelection(\n props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number },\n ): void {\n this.handleChange({ ...props, changeType: \"remove\" });\n }\n\n public replaceSelection(props: IModelKeyProp & { source: string; selectables: Selectable[]; level?: number }): void {\n this.handleChange({ ...props, changeType: \"replace\" });\n }\n\n public clearSelection(props: IModelKeyProp & { source: string; level?: number }): void {\n this.handleChange({ ...props, changeType: \"clear\", selectables: [] });\n }\n\n public clearStorage(props: IModelKeyProp): void {\n const imodelKey = getIModelKey(props);\n this.clearSelection({ source: CLEAR_SELECTION_STORAGE_SOURCE, imodelKey });\n this._storage.delete(imodelKey);\n }\n\n private getContainer(imodelKey: string): MultiLevelSelectablesContainer {\n let selectionContainer = this._storage.get(imodelKey);\n if (!selectionContainer) {\n selectionContainer = new MultiLevelSelectablesContainer();\n this._storage.set(imodelKey, selectionContainer);\n }\n return selectionContainer;\n }\n\n private handleChange(\n props: IModelKeyProp & {\n source: string;\n level?: number;\n changeType: StorageSelectionChangeType;\n selectables: Selectable[];\n },\n ) {\n const { source, level: inLevel, changeType, selectables: change } = props;\n const imodelKey = getIModelKey(props);\n const container = this.getContainer(imodelKey);\n const level = inLevel ?? 0;\n const selectables = container.getSelection(level);\n const selected = Selectables.create(change);\n switch (changeType) {\n case \"add\":\n if (!Selectables.add(selectables, change)) {\n return;\n }\n break;\n case \"remove\":\n if (!Selectables.remove(selectables, change)) {\n return;\n }\n break;\n case \"replace\":\n if (Selectables.size(selectables) === Selectables.size(selected) && Selectables.hasAll(selectables, change)) {\n return;\n }\n Selectables.clear(selectables);\n Selectables.add(selectables, change);\n break;\n case \"clear\":\n if (!Selectables.clear(selectables)) {\n return;\n }\n break;\n }\n container.clear(level + 1);\n const event: StorageSelectionChangeEventArgs = {\n source,\n level,\n imodelKey,\n iModelKey: imodelKey,\n changeType,\n selectables: selected,\n timestamp: new Date(),\n storage: this,\n };\n this.selectionChangeEvent.raiseEvent(event, this);\n }\n}\n\nfunction getIModelKey(props: IModelKeyProp): string {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n return (\"imodelKey\" in props ? props.imodelKey : props.iModelKey) ?? \"\";\n}\n\nclass MultiLevelSelectablesContainer {\n private readonly _selectablesContainers: Map<number, Selectables>;\n\n constructor() {\n this._selectablesContainers = new Map<number, Selectables>();\n }\n\n public getSelection(level: number): Selectables {\n let selectables = this._selectablesContainers.get(level);\n if (!selectables) {\n selectables = Selectables.create([]);\n this._selectablesContainers.set(level, selectables);\n }\n return selectables;\n }\n\n public getSelectionLevels(): number[] {\n const levels = new Array<number>();\n for (const entry of this._selectablesContainers.entries()) {\n if (!Selectables.isEmpty(entry[1])) {\n levels.push(entry[0]);\n }\n }\n return levels.sort();\n }\n\n public clear(level: number) {\n const storedLevels = this._selectablesContainers.keys();\n for (const storedLevel of storedLevels) {\n if (storedLevel >= level) {\n const selectables = this._selectablesContainers.get(storedLevel)!;\n Selectables.clear(selectables);\n }\n }\n }\n}\n"]}
|
|
@@ -6,4 +6,5 @@ export { createIModelHiliteSetProvider, IModelHiliteSetProvider } from "./unifie
|
|
|
6
6
|
export { computeSelection, SelectionScope } from "./unified-selection/SelectionScope.js";
|
|
7
7
|
export { enableUnifiedSelectionSyncWithIModel } from "./unified-selection/EnableUnifiedSelectionSyncWithIModel.js";
|
|
8
8
|
export { StorageSelectionChangeType, StorageSelectionChangeEventArgs, StorageSelectionChangesListener, } from "./unified-selection/SelectionChangeEvent.js";
|
|
9
|
+
export { CLEAR_SELECTION_STORAGE_SOURCE } from "./unified-selection/SelectionStorage.js";
|
|
9
10
|
//# sourceMappingURL=unified-selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,GACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AACjH,OAAO,EAEL,8BAA8B,EAE9B,wBAAwB,GACzB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,6CAA6C,CAAC"}
|
|
1
|
+
{"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,EAChB,UAAU,EACV,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,GACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AACjH,OAAO,EAEL,8BAA8B,EAE9B,wBAAwB,GACzB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AACnH,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,GAChC,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC"}
|
|
@@ -11,4 +11,5 @@ createCachingHiliteSetProvider, } from "./unified-selection/CachingHiliteSetProv
|
|
|
11
11
|
export { createIModelHiliteSetProvider } from "./unified-selection/IModelHiliteSetProvider.js";
|
|
12
12
|
export { computeSelection } from "./unified-selection/SelectionScope.js";
|
|
13
13
|
export { enableUnifiedSelectionSyncWithIModel } from "./unified-selection/EnableUnifiedSelectionSyncWithIModel.js";
|
|
14
|
+
export { CLEAR_SELECTION_STORAGE_SOURCE } from "./unified-selection/SelectionStorage.js";
|
|
14
15
|
//# sourceMappingURL=unified-selection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EACL,2BAA2B,EAE3B,UAAU,EAGV,WAAW,GACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAgC,MAAM,0CAA0C,CAAC;AACjH,OAAO;AACL,4DAA4D;AAC5D,8BAA8B,GAG/B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAA2B,MAAM,gDAAgD,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAkB,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport {\n TRANSIENT_ELEMENT_CLASSNAME,\n CustomSelectable,\n Selectable,\n SelectableIdentifier,\n SelectableInstanceKey,\n Selectables,\n} from \"./unified-selection/Selectable.js\";\nexport { SelectionStorage, createStorage } from \"./unified-selection/SelectionStorage.js\";\nexport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n createCachingHiliteSetProvider,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n CachingHiliteSetProvider,\n} from \"./unified-selection/CachingHiliteSetProvider.js\";\nexport { createIModelHiliteSetProvider, IModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport { computeSelection, SelectionScope } from \"./unified-selection/SelectionScope.js\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel.js\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n} from \"./unified-selection/SelectionChangeEvent.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EACL,2BAA2B,EAE3B,UAAU,EAGV,WAAW,GACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,uBAAuB,EAAgC,MAAM,0CAA0C,CAAC;AACjH,OAAO;AACL,4DAA4D;AAC5D,8BAA8B,GAG/B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,6BAA6B,EAA2B,MAAM,gDAAgD,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAkB,MAAM,uCAAuC,CAAC;AACzF,OAAO,EAAE,oCAAoC,EAAE,MAAM,6DAA6D,CAAC;AAMnH,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nexport {\n TRANSIENT_ELEMENT_CLASSNAME,\n CustomSelectable,\n Selectable,\n SelectableIdentifier,\n SelectableInstanceKey,\n Selectables,\n} from \"./unified-selection/Selectable.js\";\nexport { SelectionStorage, createStorage } from \"./unified-selection/SelectionStorage.js\";\nexport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider.js\";\nexport {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n createCachingHiliteSetProvider,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n CachingHiliteSetProvider,\n} from \"./unified-selection/CachingHiliteSetProvider.js\";\nexport { createIModelHiliteSetProvider, IModelHiliteSetProvider } from \"./unified-selection/IModelHiliteSetProvider.js\";\nexport { computeSelection, SelectionScope } from \"./unified-selection/SelectionScope.js\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel.js\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n} from \"./unified-selection/SelectionChangeEvent.js\";\nexport { CLEAR_SELECTION_STORAGE_SOURCE } from \"./unified-selection/SelectionStorage.js\";\n"]}
|