@itwin/unified-selection 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/README.md +104 -6
  3. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts +33 -0
  4. package/lib/cjs/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
  5. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js +62 -0
  6. package/lib/cjs/unified-selection/CachingHiliteSetProvider.js.map +1 -0
  7. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  8. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  9. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +205 -0
  10. package/lib/cjs/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  11. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts +37 -0
  12. package/lib/cjs/unified-selection/HiliteSetProvider.d.ts.map +1 -0
  13. package/lib/cjs/unified-selection/HiliteSetProvider.js +344 -0
  14. package/lib/cjs/unified-selection/HiliteSetProvider.js.map +1 -0
  15. package/lib/cjs/unified-selection/Selectable.d.ts +0 -3
  16. package/lib/cjs/unified-selection/Selectable.d.ts.map +1 -1
  17. package/lib/cjs/unified-selection/Selectable.js +2 -2
  18. package/lib/cjs/unified-selection/Selectable.js.map +1 -1
  19. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts +11 -7
  20. package/lib/cjs/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  21. package/lib/cjs/unified-selection/SelectionChangeEvent.js +1 -1
  22. package/lib/cjs/unified-selection/SelectionChangeEvent.js.map +1 -1
  23. package/lib/cjs/unified-selection/SelectionScope.d.ts +44 -0
  24. package/lib/cjs/unified-selection/SelectionScope.d.ts.map +1 -0
  25. package/lib/cjs/unified-selection/SelectionScope.js +193 -0
  26. package/lib/cjs/unified-selection/SelectionScope.js.map +1 -0
  27. package/lib/cjs/unified-selection/SelectionStorage.d.ts +34 -29
  28. package/lib/cjs/unified-selection/SelectionStorage.d.ts.map +1 -1
  29. package/lib/cjs/unified-selection/SelectionStorage.js +32 -18
  30. package/lib/cjs/unified-selection/SelectionStorage.js.map +1 -1
  31. package/lib/cjs/unified-selection/Utils.d.ts +7 -0
  32. package/lib/cjs/unified-selection/Utils.d.ts.map +1 -0
  33. package/lib/cjs/unified-selection/Utils.js +24 -0
  34. package/lib/cjs/unified-selection/Utils.js.map +1 -0
  35. package/lib/cjs/unified-selection/types/IModel.d.ts +84 -0
  36. package/lib/cjs/unified-selection/types/IModel.d.ts.map +1 -0
  37. package/lib/cjs/unified-selection/types/IModel.js +24 -0
  38. package/lib/cjs/unified-selection/types/IModel.js.map +1 -0
  39. package/lib/cjs/unified-selection.d.ts +5 -7
  40. package/lib/cjs/unified-selection.d.ts.map +1 -1
  41. package/lib/cjs/unified-selection.js +11 -7
  42. package/lib/cjs/unified-selection.js.map +1 -1
  43. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts +33 -0
  44. package/lib/esm/unified-selection/CachingHiliteSetProvider.d.ts.map +1 -0
  45. package/lib/esm/unified-selection/CachingHiliteSetProvider.js +58 -0
  46. package/lib/esm/unified-selection/CachingHiliteSetProvider.js.map +1 -0
  47. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts +90 -0
  48. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.d.ts.map +1 -0
  49. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js +200 -0
  50. package/lib/esm/unified-selection/EnableUnifiedSelectionSyncWithIModel.js.map +1 -0
  51. package/lib/esm/unified-selection/HiliteSetProvider.d.ts +37 -0
  52. package/lib/esm/unified-selection/HiliteSetProvider.d.ts.map +1 -0
  53. package/lib/esm/unified-selection/HiliteSetProvider.js +340 -0
  54. package/lib/esm/unified-selection/HiliteSetProvider.js.map +1 -0
  55. package/lib/esm/unified-selection/Selectable.d.ts +0 -3
  56. package/lib/esm/unified-selection/Selectable.d.ts.map +1 -1
  57. package/lib/esm/unified-selection/Selectable.js.map +1 -1
  58. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts +11 -7
  59. package/lib/esm/unified-selection/SelectionChangeEvent.d.ts.map +1 -1
  60. package/lib/esm/unified-selection/SelectionChangeEvent.js +1 -1
  61. package/lib/esm/unified-selection/SelectionChangeEvent.js.map +1 -1
  62. package/lib/esm/unified-selection/SelectionScope.d.ts +44 -0
  63. package/lib/esm/unified-selection/SelectionScope.d.ts.map +1 -0
  64. package/lib/esm/unified-selection/SelectionScope.js +189 -0
  65. package/lib/esm/unified-selection/SelectionScope.js.map +1 -0
  66. package/lib/esm/unified-selection/SelectionStorage.d.ts +34 -29
  67. package/lib/esm/unified-selection/SelectionStorage.d.ts.map +1 -1
  68. package/lib/esm/unified-selection/SelectionStorage.js +31 -17
  69. package/lib/esm/unified-selection/SelectionStorage.js.map +1 -1
  70. package/lib/esm/unified-selection/Utils.d.ts +7 -0
  71. package/lib/esm/unified-selection/Utils.d.ts.map +1 -0
  72. package/lib/esm/unified-selection/Utils.js +20 -0
  73. package/lib/esm/unified-selection/Utils.js.map +1 -0
  74. package/lib/esm/unified-selection/types/IModel.d.ts +84 -0
  75. package/lib/esm/unified-selection/types/IModel.d.ts.map +1 -0
  76. package/lib/esm/unified-selection/types/IModel.js +21 -0
  77. package/lib/esm/unified-selection/types/IModel.js.map +1 -0
  78. package/lib/esm/unified-selection.d.ts +5 -7
  79. package/lib/esm/unified-selection.d.ts.map +1 -1
  80. package/lib/esm/unified-selection.js +5 -7
  81. package/lib/esm/unified-selection.js.map +1 -1
  82. package/package.json +28 -15
@@ -0,0 +1,21 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /**
6
+ * Identifies the type of changes made to the `CoreIModelSelectionSet` to produce a `CoreSelectionSetEvent`.
7
+ * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/
8
+ * @internal
9
+ */
10
+ export var CoreSelectionSetEventType;
11
+ (function (CoreSelectionSetEventType) {
12
+ /** Elements have been added to the set. */
13
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Add"] = 0] = "Add";
14
+ /** Elements have been removed from the set. */
15
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Remove"] = 1] = "Remove";
16
+ /** Some elements have been added to the set and others have been removed. */
17
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Replace"] = 2] = "Replace";
18
+ /** All elements are about to be removed from the set. */
19
+ CoreSelectionSetEventType[CoreSelectionSetEventType["Clear"] = 3] = "Clear";
20
+ })(CoreSelectionSetEventType || (CoreSelectionSetEventType = {}));
21
+ //# sourceMappingURL=IModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModel.js","sourceRoot":"","sources":["../../../../src/unified-selection/types/IModel.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAKhG;;;;GAIG;AACH,MAAM,CAAN,IAAY,yBASX;AATD,WAAY,yBAAyB;IACnC,2CAA2C;IAC3C,uEAAG,CAAA;IACH,+CAA+C;IAC/C,6EAAM,CAAA;IACN,6EAA6E;IAC7E,+EAAO,CAAA;IACP,yDAAyD;IACzD,2EAAK,CAAA;AACP,CAAC,EATW,yBAAyB,KAAzB,yBAAyB,QASpC","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 { Id64Arg } from \"@itwin/core-bentley\";\nimport { Event } from \"@itwin/presentation-shared\";\n\n/**\n * Identifies the type of changes made to the `CoreIModelSelectionSet` to produce a `CoreSelectionSetEvent`.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/\n * @internal\n */\nexport enum CoreSelectionSetEventType {\n /** Elements have been added to the set. */\n Add,\n /** Elements have been removed from the set. */\n Remove,\n /** Some elements have been added to the set and others have been removed. */\n Replace,\n /** All elements are about to be removed from the set. */\n Clear,\n}\n\n/**\n * Payload sent to `CoreIModelSelectionSet.onChanged` event listeners to describe how the contents of the set have changed.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/selectionsetevent/\n * @internal\n */\nexport interface CoreSelectionSetEventUnsafe {\n /**\n * The type of operation that produced this event.\n *\n * Actually, this should be `CoreSelectionSetEventType`, however we can't use it here because in TS two identical enums with\n * different names aren't equal, so [`SelectionSetEventType `](https://www.itwinjs.org/reference/core-frontend/selectionset/selectionseteventtype/)\n * doesn't map to `CoreSelectionSetEventType` as far as TS is concerned. Due to this reason, this interface is marked as `unsafe`.\n */\n type: number;\n /** The element Ids added to the set. */\n added?: Id64Arg;\n /** The element Ids removed from the set. */\n removed?: Id64Arg;\n /** The affected `CoreIModelSelectionSet`. */\n set: CoreIModelSelectionSet;\n}\n\n/**\n * A set of *currently selected* elements in an iModel.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/\n * @internal\n */\nexport interface CoreIModelSelectionSet {\n /** Event called whenever elements are added or removed from this SelectionSet. */\n onChanged: Event<(ev: CoreSelectionSetEventUnsafe) => void>;\n /** The IDs of the selected elements. */\n readonly elements: Set<string>;\n /** Clear current selection set. */\n emptyAll(): void;\n /** Add one or more Ids to the current selection set. */\n add(elem: Id64Arg): boolean;\n /** Remove one or more Ids from the current selection set. */\n remove(elem: Id64Arg): boolean;\n}\n\n/**\n * A set if ID's optimized for performance-critical code which represents large sets of ID's as pairs of 32-bit integers.\n * @see https://www.itwinjs.org/reference/core-bentley/ids/id64/id64.uint32set/\n */\ninterface Uint32Set {\n /** Add any number of Ids to the set. */\n addIds(ids: Id64Arg): void;\n /** Remove any number of Ids from the set. */\n deleteIds(ids: Id64Arg): void;\n}\n\n/**\n * A set of *hilited* elements in an iModel, by element id.\n * @see https://www.itwinjs.org/reference/core-frontend/selectionset/hiliteset/\n * @internal\n */\nexport interface CoreIModelHiliteSet {\n /** Control whether the hilited elements should be synchronized with the contents of `CoreIModelSelectionSet`.*/\n wantSyncWithSelectionSet: boolean;\n /** The set of hilited elements. */\n readonly elements: Uint32Set;\n /** The set of hilited subcategories. */\n readonly subcategories: Uint32Set;\n /** The set of hilited models. */\n readonly models: Uint32Set;\n /** Remove all elements from the hilited set. */\n clear(): void;\n}\n"]}
@@ -1,10 +1,8 @@
1
- /**
2
- * @module UnifiedSelection
3
- *
4
- * @docs-group-description UnifiedSelection
5
- * API for working with unified selection.
6
- */
7
1
  export * from "./unified-selection/Selectable";
8
- export * from "./unified-selection/SelectionStorage";
2
+ export { SelectionStorage, createStorage } from "./unified-selection/SelectionStorage";
3
+ export { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from "./unified-selection/HiliteSetProvider";
4
+ export { createCachingHiliteSetProvider, CachingHiliteSetProvider } from "./unified-selection/CachingHiliteSetProvider";
5
+ export { computeSelection } from "./unified-selection/SelectionScope";
6
+ export { enableUnifiedSelectionSyncWithIModel } from "./unified-selection/EnableUnifiedSelectionSyncWithIModel";
9
7
  export { StorageSelectionChangeType, StorageSelectionChangeEventArgs, StorageSelectionChangesListener, SelectionChangeEvent, } from "./unified-selection/SelectionChangeEvent";
10
8
  //# 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;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,CAAC;AACrD,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,0CAA0C,CAAC"}
1
+ {"version":3,"file":"unified-selection.d.ts","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAKA,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,0DAA0D,CAAC;AAChH,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,0CAA0C,CAAC"}
@@ -2,12 +2,10 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- /**
6
- * @module UnifiedSelection
7
- *
8
- * @docs-group-description UnifiedSelection
9
- * API for working with unified selection.
10
- */
11
5
  export * from "./unified-selection/Selectable";
12
- export * from "./unified-selection/SelectionStorage";
6
+ export { createStorage } from "./unified-selection/SelectionStorage";
7
+ export { createHiliteSetProvider } from "./unified-selection/HiliteSetProvider";
8
+ export { createCachingHiliteSetProvider } from "./unified-selection/CachingHiliteSetProvider";
9
+ export { computeSelection } from "./unified-selection/SelectionScope";
10
+ export { enableUnifiedSelectionSyncWithIModel } from "./unified-selection/EnableUnifiedSelectionSyncWithIModel";
13
11
  //# 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;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sCAAsC,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\n/**\n * @module UnifiedSelection\n *\n * @docs-group-description UnifiedSelection\n * API for working with unified selection.\n */\nexport * from \"./unified-selection/Selectable\";\nexport * from \"./unified-selection/SelectionStorage\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n SelectionChangeEvent,\n} from \"./unified-selection/SelectionChangeEvent\";\n"]}
1
+ {"version":3,"file":"unified-selection.js","sourceRoot":"","sources":["../../src/unified-selection.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAoB,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAgC,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,8BAA8B,EAA4B,MAAM,8CAA8C,CAAC;AACxH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,oCAAoC,EAAE,MAAM,0DAA0D,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 * from \"./unified-selection/Selectable\";\nexport { SelectionStorage, createStorage } from \"./unified-selection/SelectionStorage\";\nexport { createHiliteSetProvider, HiliteSet, HiliteSetProvider } from \"./unified-selection/HiliteSetProvider\";\nexport { createCachingHiliteSetProvider, CachingHiliteSetProvider } from \"./unified-selection/CachingHiliteSetProvider\";\nexport { computeSelection } from \"./unified-selection/SelectionScope\";\nexport { enableUnifiedSelectionSyncWithIModel } from \"./unified-selection/EnableUnifiedSelectionSyncWithIModel\";\nexport {\n StorageSelectionChangeType,\n StorageSelectionChangeEventArgs,\n StorageSelectionChangesListener,\n SelectionChangeEvent,\n} from \"./unified-selection/SelectionChangeEvent\";\n"]}
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@itwin/unified-selection",
3
- "version": "0.1.0",
4
- "description": "Package for managing unified selection",
3
+ "version": "0.3.0",
4
+ "description": "Package for managing unified selection in iTwin.js applications.",
5
+ "license": "MIT",
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "https://github.com/iTwin/presentation.git",
@@ -9,9 +10,15 @@
9
10
  },
10
11
  "keywords": [
11
12
  "Bentley",
12
- "EC",
13
- "Unified selection",
14
- "iTwin.js"
13
+ "Highlight",
14
+ "Hilite",
15
+ "iTwin.js",
16
+ "Presentation",
17
+ "Selection",
18
+ "Selection level",
19
+ "Selection scope",
20
+ "Selection storage",
21
+ "Unified selection"
15
22
  ],
16
23
  "author": {
17
24
  "name": "Bentley Systems, Inc.",
@@ -20,26 +27,32 @@
20
27
  "main": "lib/cjs/unified-selection.js",
21
28
  "module": "lib/esm/unified-selection.js",
22
29
  "types": "lib/cjs/unified-selection.d.ts",
23
- "dependencies": {},
30
+ "dependencies": {
31
+ "@itwin/core-bentley": "^4.5.2",
32
+ "rxjs": "^7.8.1",
33
+ "rxjs-for-await": "^1.0.0",
34
+ "@itwin/presentation-shared": "^0.1.0"
35
+ },
24
36
  "devDependencies": {
25
- "@itwin/build-tools": "^4.4.0",
26
- "@itwin/eslint-plugin": "4.0.0-dev.48",
27
- "@types/chai": "^4.3.11",
37
+ "@itwin/build-tools": "^4.5.2",
38
+ "@itwin/eslint-plugin": "^4.0.0",
39
+ "@types/chai": "^4.3.14",
28
40
  "@types/chai-as-promised": "^7.1.8",
29
41
  "@types/mocha": "^10.0.6",
30
- "@types/node": "^18.17.7",
42
+ "@types/node": "^18.19.31",
31
43
  "@types/sinon": "^17.0.3",
32
44
  "@types/sinon-chai": "^3.2.12",
33
45
  "chai": "^4.4.1",
34
46
  "chai-as-promised": "^7.1.1",
35
47
  "cpx2": "^7.0.1",
36
- "eslint": "^8.56.0",
37
- "mocha": "^10.3.0",
48
+ "eslint": "^8.57.0",
49
+ "mocha": "^10.4.0",
38
50
  "nyc": "^15.1.0",
51
+ "rimraf": "^5.0.5",
39
52
  "sinon": "^17.0.1",
40
53
  "sinon-chai": "^3.7.0",
41
- "source-map-support": "^0.5.21",
42
- "typescript": "~5.0.4"
54
+ "typescript": "~5.4.5",
55
+ "presentation-test-utilities": "^0.0.0"
43
56
  },
44
57
  "scripts": {
45
58
  "build": "npm run -s build:cjs && npm run -s build:esm",
@@ -49,7 +62,7 @@
49
62
  "clean": "rimraf lib build",
50
63
  "cover": "nyc npm -s test",
51
64
  "lint": "eslint ./src/**/*.ts",
52
- "test": "mocha --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"",
65
+ "test": "mocha --enable-source-maps --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"",
53
66
  "test:watch": "npm -s test -- --reporter min --watch-extensions ts --watch",
54
67
  "extract-api": "betools extract-api --entry=unified-selection --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api",
55
68
  "check-internal": "node ../../scripts/checkInternal.js --apiSummary ./api/unified-selection.api.md"