@itwin/presentation-frontend 4.0.0-dev.8 → 4.0.0-dev.81
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 +45 -1
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +47 -47
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/cjs/presentation-frontend/Diagnostics.d.ts +14 -14
- package/lib/cjs/presentation-frontend/Diagnostics.js +61 -61
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
- package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +20 -20
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +9 -10
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +32 -41
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +10 -10
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +31 -31
- package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.d.ts +73 -75
- package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/Presentation.js +159 -162
- package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +207 -186
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/PresentationManager.js +442 -436
- package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/RulesetManager.d.ts +63 -63
- package/lib/cjs/presentation-frontend/RulesetManager.js +85 -85
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +195 -195
- package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +520 -518
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +290 -293
- package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
- package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +97 -97
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
- package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +9 -9
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
- package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +33 -33
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
- package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +108 -108
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +17 -14
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +40 -37
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +139 -139
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js +414 -414
- package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +91 -91
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/cjs/presentation-frontend.d.ts +33 -34
- package/lib/cjs/presentation-frontend.d.ts.map +1 -1
- package/lib/cjs/presentation-frontend.js +53 -50
- package/lib/cjs/presentation-frontend.js.map +1 -1
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +43 -43
- package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
- package/lib/esm/presentation-frontend/Diagnostics.d.ts +14 -14
- package/lib/esm/presentation-frontend/Diagnostics.js +56 -56
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
- package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +17 -17
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +9 -10
- package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +28 -37
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +10 -10
- package/lib/esm/presentation-frontend/LocalizationHelper.js +27 -27
- package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.d.ts +73 -75
- package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/Presentation.js +155 -158
- package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +207 -186
- package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/PresentationManager.js +437 -431
- package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
- package/lib/esm/presentation-frontend/RulesetManager.d.ts +63 -63
- package/lib/esm/presentation-frontend/RulesetManager.js +81 -81
- package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js +191 -191
- package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +515 -512
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +282 -285
- package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
- package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +93 -93
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
- package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +8 -8
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
- package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +29 -29
- package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
- package/lib/esm/presentation-frontend/selection/SelectionHandler.js +104 -104
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +17 -14
- package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +36 -33
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +139 -139
- package/lib/esm/presentation-frontend/selection/SelectionManager.js +409 -409
- package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +85 -85
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
- package/lib/esm/presentation-frontend.d.ts +33 -34
- package/lib/esm/presentation-frontend.d.ts.map +1 -1
- package/lib/esm/presentation-frontend.js +37 -38
- package/lib/esm/presentation-frontend.js.map +1 -1
- package/package.json +22 -20
- package/lib/cjs/presentation-frontend/StateTracker.d.ts +0 -39
- package/lib/cjs/presentation-frontend/StateTracker.d.ts.map +0 -1
- package/lib/cjs/presentation-frontend/StateTracker.js +0 -130
- package/lib/cjs/presentation-frontend/StateTracker.js.map +0 -1
- package/lib/esm/presentation-frontend/StateTracker.d.ts +0 -39
- package/lib/esm/presentation-frontend/StateTracker.d.ts.map +0 -1
- package/lib/esm/presentation-frontend/StateTracker.js +0 -126
- package/lib/esm/presentation-frontend/StateTracker.js.map +0 -1
|
@@ -1,39 +1,38 @@
|
|
|
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
|
-
* @module Core
|
|
7
|
-
*
|
|
8
|
-
* @docs-group-description Core
|
|
9
|
-
* Common types used for retrieving presentation data from iModels.
|
|
10
|
-
*/
|
|
11
|
-
export * from "./presentation-frontend/Presentation";
|
|
12
|
-
export * from "./presentation-frontend/PresentationManager";
|
|
13
|
-
export * from "./presentation-frontend/RulesetManager";
|
|
14
|
-
export * from "./presentation-frontend/RulesetVariablesManager";
|
|
15
|
-
export * from "./presentation-frontend/favorite-properties/FavoritePropertiesManager";
|
|
16
|
-
export * from "./presentation-frontend/favorite-properties/FavoritePropertiesStorage";
|
|
17
|
-
export * from "./presentation-frontend/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export * from "./presentation-frontend/selection/
|
|
33
|
-
export * from "./presentation-frontend/selection/
|
|
34
|
-
export * from "./presentation-frontend/selection/
|
|
35
|
-
export * from "./presentation-frontend/selection/
|
|
36
|
-
export * from "./presentation-frontend/selection/
|
|
37
|
-
export * from "./presentation-frontend/selection/
|
|
38
|
-
export * from "./presentation-frontend/selection/SelectionHelper";
|
|
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
|
+
* @module Core
|
|
7
|
+
*
|
|
8
|
+
* @docs-group-description Core
|
|
9
|
+
* Common types used for retrieving presentation data from iModels.
|
|
10
|
+
*/
|
|
11
|
+
export * from "./presentation-frontend/Presentation";
|
|
12
|
+
export * from "./presentation-frontend/PresentationManager";
|
|
13
|
+
export * from "./presentation-frontend/RulesetManager";
|
|
14
|
+
export * from "./presentation-frontend/RulesetVariablesManager";
|
|
15
|
+
export * from "./presentation-frontend/favorite-properties/FavoritePropertiesManager";
|
|
16
|
+
export * from "./presentation-frontend/favorite-properties/FavoritePropertiesStorage";
|
|
17
|
+
export * from "./presentation-frontend/Diagnostics";
|
|
18
|
+
/**
|
|
19
|
+
* @module Logging
|
|
20
|
+
*
|
|
21
|
+
* @docs-group-description Logging
|
|
22
|
+
* Types related to logging in this package.
|
|
23
|
+
*/
|
|
24
|
+
export * from "./presentation-frontend/FrontendLoggerCategory";
|
|
25
|
+
/**
|
|
26
|
+
* @module UnifiedSelection
|
|
27
|
+
*
|
|
28
|
+
* @docs-group-description UnifiedSelection
|
|
29
|
+
* Types related to [unified selection]($docs/presentation/unified-selection/index.md).
|
|
30
|
+
*/
|
|
31
|
+
export * from "./presentation-frontend/selection/SelectionChangeEvent";
|
|
32
|
+
export * from "./presentation-frontend/selection/ISelectionProvider";
|
|
33
|
+
export * from "./presentation-frontend/selection/SelectionManager";
|
|
34
|
+
export * from "./presentation-frontend/selection/SelectionScopesManager";
|
|
35
|
+
export * from "./presentation-frontend/selection/SelectionHandler";
|
|
36
|
+
export * from "./presentation-frontend/selection/HiliteSetProvider";
|
|
37
|
+
export * from "./presentation-frontend/selection/SelectionHelper";
|
|
39
38
|
//# sourceMappingURL=presentation-frontend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-frontend.js","sourceRoot":"","sources":["../../src/presentation-frontend.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,iDAAiD,CAAC;AAChE,cAAc,uEAAuE,CAAC;AACtF,cAAc,uEAAuE,CAAC;AACtF,cAAc,
|
|
1
|
+
{"version":3,"file":"presentation-frontend.js","sourceRoot":"","sources":["../../src/presentation-frontend.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,cAAc,sCAAsC,CAAC;AACrD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,iDAAiD,CAAC;AAChE,cAAc,uEAAuE,CAAC;AACtF,cAAc,uEAAuE,CAAC;AACtF,cAAc,qCAAqC,CAAC;AAEpD;;;;;GAKG;AACH,cAAc,gDAAgD,CAAC;AAE/D;;;;;GAKG;AACH,cAAc,wDAAwD,CAAC;AACvE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,qDAAqD,CAAC;AACpE,cAAc,mDAAmD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/**\r\n * @module Core\r\n *\r\n * @docs-group-description Core\r\n * Common types used for retrieving presentation data from iModels.\r\n */\r\nexport * from \"./presentation-frontend/Presentation\";\r\nexport * from \"./presentation-frontend/PresentationManager\";\r\nexport * from \"./presentation-frontend/RulesetManager\";\r\nexport * from \"./presentation-frontend/RulesetVariablesManager\";\r\nexport * from \"./presentation-frontend/favorite-properties/FavoritePropertiesManager\";\r\nexport * from \"./presentation-frontend/favorite-properties/FavoritePropertiesStorage\";\r\nexport * from \"./presentation-frontend/Diagnostics\";\r\n\r\n/**\r\n * @module Logging\r\n *\r\n * @docs-group-description Logging\r\n * Types related to logging in this package.\r\n */\r\nexport * from \"./presentation-frontend/FrontendLoggerCategory\";\r\n\r\n/**\r\n * @module UnifiedSelection\r\n *\r\n * @docs-group-description UnifiedSelection\r\n * Types related to [unified selection]($docs/presentation/unified-selection/index.md).\r\n */\r\nexport * from \"./presentation-frontend/selection/SelectionChangeEvent\";\r\nexport * from \"./presentation-frontend/selection/ISelectionProvider\";\r\nexport * from \"./presentation-frontend/selection/SelectionManager\";\r\nexport * from \"./presentation-frontend/selection/SelectionScopesManager\";\r\nexport * from \"./presentation-frontend/selection/SelectionHandler\";\r\nexport * from \"./presentation-frontend/selection/HiliteSetProvider\";\r\nexport * from \"./presentation-frontend/selection/SelectionHelper\";\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-frontend",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.81",
|
|
4
4
|
"description": "Frontend of iModel.js Presentation library",
|
|
5
5
|
"main": "lib/cjs/presentation-frontend.js",
|
|
6
6
|
"module": "lib/esm/presentation-frontend.js",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/iTwin/itwinjs-core
|
|
11
|
+
"url": "https://github.com/iTwin/itwinjs-core.git",
|
|
12
|
+
"directory": "presentation/frontend"
|
|
12
13
|
},
|
|
13
14
|
"keywords": [
|
|
14
15
|
"Bentley",
|
|
@@ -22,28 +23,30 @@
|
|
|
22
23
|
"url": "http://www.bentley.com"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
|
-
"@itwin/core-bentley": "^4.0.0-dev.
|
|
26
|
-
"@itwin/core-common": "^4.0.0-dev.
|
|
27
|
-
"@itwin/core-frontend": "^4.0.0-dev.
|
|
28
|
-
"@itwin/core-quantity": "^4.0.0-dev.
|
|
29
|
-
"@itwin/
|
|
26
|
+
"@itwin/core-bentley": "^4.0.0-dev.81",
|
|
27
|
+
"@itwin/core-common": "^4.0.0-dev.81",
|
|
28
|
+
"@itwin/core-frontend": "^4.0.0-dev.81",
|
|
29
|
+
"@itwin/core-quantity": "^4.0.0-dev.81",
|
|
30
|
+
"@itwin/ecschema-metadata": "^4.0.0-dev.81",
|
|
31
|
+
"@itwin/presentation-common": "^4.0.0-dev.81"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
|
-
"@itwin/build-tools": "4.0.0-dev.
|
|
33
|
-
"@itwin/core-bentley": "4.0.0-dev.
|
|
34
|
-
"@itwin/core-common": "4.0.0-dev.
|
|
35
|
-
"@itwin/core-frontend": "4.0.0-dev.
|
|
36
|
-
"@itwin/core-i18n": "4.0.0-dev.
|
|
37
|
-
"@itwin/core-quantity": "4.0.0-dev.
|
|
38
|
-
"@itwin/
|
|
39
|
-
"@itwin/
|
|
34
|
+
"@itwin/build-tools": "4.0.0-dev.81",
|
|
35
|
+
"@itwin/core-bentley": "4.0.0-dev.81",
|
|
36
|
+
"@itwin/core-common": "4.0.0-dev.81",
|
|
37
|
+
"@itwin/core-frontend": "4.0.0-dev.81",
|
|
38
|
+
"@itwin/core-i18n": "4.0.0-dev.81",
|
|
39
|
+
"@itwin/core-quantity": "4.0.0-dev.81",
|
|
40
|
+
"@itwin/ecschema-metadata": "4.0.0-dev.81",
|
|
41
|
+
"@itwin/eslint-plugin": "^4.0.0-dev.33",
|
|
42
|
+
"@itwin/presentation-common": "4.0.0-dev.81",
|
|
40
43
|
"@types/chai": "4.3.1",
|
|
41
44
|
"@types/chai-as-promised": "^7",
|
|
42
45
|
"@types/chai-jest-snapshot": "^1.3.0",
|
|
43
46
|
"@types/deep-equal": "^1",
|
|
44
47
|
"@types/faker": "^4.1.0",
|
|
45
48
|
"@types/mocha": "^8.2.2",
|
|
46
|
-
"@types/node": "18.11.5",
|
|
49
|
+
"@types/node": "^18.11.5",
|
|
47
50
|
"@types/sinon": "^9.0.0",
|
|
48
51
|
"@types/sinon-chai": "^3.2.0",
|
|
49
52
|
"chai": "^4.1.2",
|
|
@@ -52,7 +55,7 @@
|
|
|
52
55
|
"cpx2": "^3.0.0",
|
|
53
56
|
"cross-env": "^5.1.4",
|
|
54
57
|
"deep-equal": "^1",
|
|
55
|
-
"eslint": "^
|
|
58
|
+
"eslint": "^8.36.0",
|
|
56
59
|
"faker": "^4.1.0",
|
|
57
60
|
"jsdom": "^19.0.0",
|
|
58
61
|
"jsdom-global": "3.0.2",
|
|
@@ -63,7 +66,7 @@
|
|
|
63
66
|
"sinon-chai": "^3.2.0",
|
|
64
67
|
"source-map-support": "^0.5.6",
|
|
65
68
|
"typemoq": "^2.1.0",
|
|
66
|
-
"typescript": "~
|
|
69
|
+
"typescript": "~5.0.2"
|
|
67
70
|
},
|
|
68
71
|
"nyc": {
|
|
69
72
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|
|
@@ -75,8 +78,7 @@
|
|
|
75
78
|
"extends": "plugin:@itwin/itwinjs-recommended"
|
|
76
79
|
},
|
|
77
80
|
"scripts": {
|
|
78
|
-
"build": "npm run -s build:cjs",
|
|
79
|
-
"build:ci": "npm run -s build && npm run -s build:esm",
|
|
81
|
+
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
80
82
|
"build:cjs": "npm run -s copy:cjs && tsc -p tsconfig.cjs.json",
|
|
81
83
|
"build:esm": "npm run -s copy:esm && tsc -p tsconfig.esm.json",
|
|
82
84
|
"copy:cjs": "cpx \"./src/**/*.json\" ./lib/cjs",
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Core
|
|
3
|
-
*/
|
|
4
|
-
import { IModelConnection } from "@itwin/core-frontend";
|
|
5
|
-
import { NodeKey } from "@itwin/presentation-common";
|
|
6
|
-
import { IpcRequestsHandler } from "./IpcRequestsHandler";
|
|
7
|
-
/**
|
|
8
|
-
* Data structure that describes information used by [[StateTracker]] to identify node.
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export interface NodeIdentifier {
|
|
12
|
-
id: string;
|
|
13
|
-
key: NodeKey;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export interface NodeState {
|
|
19
|
-
isExpanded?: boolean;
|
|
20
|
-
instanceFilter?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
|
|
24
|
-
* just the state changes to the backend as soon as component sends in a new hierarchy state.
|
|
25
|
-
*
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare class StateTracker {
|
|
29
|
-
private _hierarchyStates;
|
|
30
|
-
private _ipcRequestsHandler;
|
|
31
|
-
constructor(ipcRequestsHandler: IpcRequestsHandler);
|
|
32
|
-
private updateHierarchyStateIfNeeded;
|
|
33
|
-
onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string): Promise<void>;
|
|
34
|
-
onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{
|
|
35
|
-
node: NodeIdentifier | undefined;
|
|
36
|
-
state: NodeState;
|
|
37
|
-
}>): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=StateTracker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StateTracker.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAgBD;;;;;GAKG;AACH,qBAAa,YAAY;IAEvB,OAAO,CAAC,gBAAgB,CAAwD;IAChF,OAAO,CAAC,mBAAmB,CAAqB;gBAEpC,kBAAkB,EAAE,kBAAkB;YAKpC,4BAA4B;IAM7B,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAmB/E,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;CA+DrL"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module Core
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.StateTracker = void 0;
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
-
/**
|
|
13
|
-
* The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
|
|
14
|
-
* just the state changes to the backend as soon as component sends in a new hierarchy state.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
class StateTracker {
|
|
19
|
-
constructor(ipcRequestsHandler) {
|
|
20
|
-
this._ipcRequestsHandler = ipcRequestsHandler;
|
|
21
|
-
this._hierarchyStates = new Map();
|
|
22
|
-
}
|
|
23
|
-
async updateHierarchyStateIfNeeded(imodelKey, rulesetId, stateChanges) {
|
|
24
|
-
if (stateChanges.length === 0)
|
|
25
|
-
return;
|
|
26
|
-
await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, stateChanges });
|
|
27
|
-
}
|
|
28
|
-
async onHierarchyClosed(imodel, rulesetId, sourceId) {
|
|
29
|
-
const hierarchyState = this._hierarchyStates.get(rulesetId);
|
|
30
|
-
if (!hierarchyState)
|
|
31
|
-
return;
|
|
32
|
-
const stateChanges = [];
|
|
33
|
-
hierarchyState.forEach((entry) => {
|
|
34
|
-
if (!entry.states.has(sourceId)) {
|
|
35
|
-
// the node has no state for this source - nothing to do
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
(0, core_bentley_1.using)(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {
|
|
39
|
-
entry.states.delete(sourceId);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);
|
|
43
|
-
}
|
|
44
|
-
async onHierarchyStateChanged(imodel, rulesetId, sourceId, newHierarchyState) {
|
|
45
|
-
let hierarchyState = this._hierarchyStates.get(rulesetId);
|
|
46
|
-
if (!hierarchyState) {
|
|
47
|
-
if (newHierarchyState.length === 0)
|
|
48
|
-
return;
|
|
49
|
-
hierarchyState = new Map();
|
|
50
|
-
this._hierarchyStates.set(rulesetId, hierarchyState);
|
|
51
|
-
}
|
|
52
|
-
const handledNodeIds = new Set();
|
|
53
|
-
const stateChanges = [];
|
|
54
|
-
// step 1: walk over new state and report all changes
|
|
55
|
-
newHierarchyState.forEach(({ node, state }) => {
|
|
56
|
-
const nodeId = node === null || node === void 0 ? void 0 : node.id;
|
|
57
|
-
const nodeKey = node === null || node === void 0 ? void 0 : node.key;
|
|
58
|
-
const existingNodeEntry = hierarchyState.get(nodeId);
|
|
59
|
-
if (existingNodeEntry) {
|
|
60
|
-
(0, core_bentley_1.using)(new MergedNodeStateChangeReporter(existingNodeEntry, stateChanges), (_) => {
|
|
61
|
-
existingNodeEntry.states.set(sourceId, state);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
hierarchyState.set(nodeId, { key: nodeKey, states: new Map([[sourceId, state]]) });
|
|
66
|
-
stateChanges.push({ ...calculateMergedNodeState([state].values()), nodeKey });
|
|
67
|
-
}
|
|
68
|
-
handledNodeIds.add(nodeId);
|
|
69
|
-
});
|
|
70
|
-
// step 2: walk over old state and remove all state that's not in the new state
|
|
71
|
-
const erasedNodeIds = new Set();
|
|
72
|
-
hierarchyState.forEach((entry, nodeId) => {
|
|
73
|
-
if (handledNodeIds.has(nodeId)) {
|
|
74
|
-
// the node was handled with the new state - nothing to do here
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
if (!entry.states.has(sourceId)) {
|
|
78
|
-
// the node had no state for this source, so it's not affected by this report
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
(0, core_bentley_1.using)(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {
|
|
82
|
-
entry.states.delete(sourceId);
|
|
83
|
-
});
|
|
84
|
-
// istanbul ignore next
|
|
85
|
-
if (entry.states.size === 0) {
|
|
86
|
-
// there are no more components holding state for this node
|
|
87
|
-
erasedNodeIds.add(nodeId);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
// step 3: cleanup erased node ids and possibly the whole hierarchy state
|
|
91
|
-
for (const nodeId of erasedNodeIds) {
|
|
92
|
-
hierarchyState.delete(nodeId);
|
|
93
|
-
}
|
|
94
|
-
if (hierarchyState.size === 0)
|
|
95
|
-
this._hierarchyStates.delete(rulesetId);
|
|
96
|
-
// finally, report
|
|
97
|
-
await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.StateTracker = StateTracker;
|
|
101
|
-
function calculateMergedNodeState(perComponentStates) {
|
|
102
|
-
const merged = {};
|
|
103
|
-
for (const state of perComponentStates) {
|
|
104
|
-
if (state.isExpanded)
|
|
105
|
-
merged.isExpanded = true;
|
|
106
|
-
if (state.instanceFilter) {
|
|
107
|
-
if (!merged.instanceFilters)
|
|
108
|
-
merged.instanceFilters = [state.instanceFilter];
|
|
109
|
-
else if (!merged.instanceFilters.includes(state.instanceFilter))
|
|
110
|
-
merged.instanceFilters.push(state.instanceFilter);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return merged;
|
|
114
|
-
}
|
|
115
|
-
class MergedNodeStateChangeReporter {
|
|
116
|
-
constructor(entry, outStateChanges) {
|
|
117
|
-
this._entry = entry;
|
|
118
|
-
this._stateBefore = calculateMergedNodeState(this._entry.states.values());
|
|
119
|
-
this._outStateChanges = outStateChanges;
|
|
120
|
-
}
|
|
121
|
-
dispose() {
|
|
122
|
-
var _a, _b, _c, _d;
|
|
123
|
-
const stateAfter = calculateMergedNodeState(this._entry.states.values());
|
|
124
|
-
const expandedFlagsDiffer = !!stateAfter.isExpanded !== !!this._stateBefore.isExpanded;
|
|
125
|
-
const instanceFiltersDiffer = ((_b = (_a = stateAfter.instanceFilters) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) !== ((_d = (_c = this._stateBefore.instanceFilters) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0);
|
|
126
|
-
if (expandedFlagsDiffer || instanceFiltersDiffer)
|
|
127
|
-
this._outStateChanges.push({ ...stateAfter, nodeKey: this._entry.key });
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
//# sourceMappingURL=StateTracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StateTracker.js","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAyD;AAoCzD;;;;;GAKG;AACH,MAAa,YAAY;IAKvB,YAAY,kBAAsC;QAChD,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;QAC9C,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;IACpC,CAAC;IAEO,KAAK,CAAC,4BAA4B,CAAC,SAAiB,EAAE,SAAiB,EAAE,YAAiC;QAChH,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAC3B,OAAO;QACT,MAAM,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;IAC9F,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,MAAwB,EAAE,SAAiB,EAAE,QAAgB;QAC1F,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAC5D,IAAI,CAAC,cAAc;YACjB,OAAO;QAET,MAAM,YAAY,GAAwB,EAAE,CAAC;QAC7C,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;YAC/B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,Q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AAM,EAAE,CAAC,CAAC;QACzE,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACvF,MAAM,qBAAqB,GAAG,CAAC,MAAA,MAAA,UAAU,CAAC,eAAe,0CAAE,MAAM,mCAAI,CAAC,CAAC,KAAK,CAAC,MAAA,MAAA,IAAI,CAAC,YAAY,CAAC,eAAe,0CAAE,MAAM,mCAAI,CAAC,CAAC,CAAC;QAC7H,IAAI,mBAAmB,IAAI,qBAAqB;YAC9C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { NodeKey } from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\n\r\n/**\r\n * Data structure that describes information used by [[StateTracker]] to identify node.\r\n * @internal\r\n */\r\nexport interface NodeIdentifier {\r\n id: string;\r\n key: NodeKey;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface NodeState {\r\n isExpanded?: boolean;\r\n instanceFilter?: string;\r\n}\r\n\r\ninterface MergedNodeState {\r\n isExpanded?: boolean;\r\n instanceFilters?: string[];\r\n}\r\n\r\ninterface ReportedNodeState extends MergedNodeState {\r\n nodeKey: NodeKey | undefined;\r\n}\r\n\r\ninterface NodeStatesEntry {\r\n key: NodeKey | undefined;\r\n states: Map<string, NodeState>; // per-component node state\r\n}\r\n\r\n/**\r\n * The tracker stores up-to-date UI state of the hierarchies on the frontend and reports\r\n * just the state changes to the backend as soon as component sends in a new hierarchy state.\r\n *\r\n * @internal\r\n */\r\nexport class StateTracker {\r\n // Ruleset ID => Node ID => Node state info\r\n private _hierarchyStates: Map<string, Map<string | undefined, NodeStatesEntry>>;\r\n private _ipcRequestsHandler: IpcRequestsHandler;\r\n\r\n constructor(ipcRequestsHandler: IpcRequestsHandler) {\r\n this._ipcRequestsHandler = ipcRequestsHandler;\r\n this._hierarchyStates = new Map();\r\n }\r\n\r\n private async updateHierarchyStateIfNeeded(imodelKey: string, rulesetId: string, stateChanges: ReportedNodeState[]) {\r\n if (stateChanges.length === 0)\r\n return;\r\n await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, stateChanges });\r\n }\r\n\r\n public async onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string) {\r\n const hierarchyState = this._hierarchyStates.get(rulesetId);\r\n if (!hierarchyState)\r\n return;\r\n\r\n const stateChanges: ReportedNodeState[] = [];\r\n hierarchyState.forEach((entry) => {\r\n if (!entry.states.has(sourceId)) {\r\n // the node has no state for this source - nothing to do\r\n return;\r\n }\r\n using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {\r\n entry.states.delete(sourceId);\r\n });\r\n });\r\n\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);\r\n }\r\n\r\n public async onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{ node: NodeIdentifier | undefined, state: NodeState }>) {\r\n let hierarchyState = this._hierarchyStates.get(rulesetId);\r\n if (!hierarchyState) {\r\n if (newHierarchyState.length === 0)\r\n return;\r\n\r\n hierarchyState = new Map();\r\n this._hierarchyStates.set(rulesetId, hierarchyState);\r\n }\r\n\r\n const handledNodeIds = new Set<string | undefined>();\r\n const stateChanges: ReportedNodeState[] = [];\r\n\r\n // step 1: walk over new state and report all changes\r\n newHierarchyState.forEach(({ node, state }) => {\r\n const nodeId = node?.id;\r\n const nodeKey = node?.key;\r\n const existingNodeEntry = hierarchyState!.get(nodeId);\r\n if (existingNodeEntry) {\r\n using(new MergedNodeStateChangeReporter(existingNodeEntry, stateChanges), (_) => {\r\n existingNodeEntry.states.set(sourceId, state);\r\n });\r\n } else {\r\n hierarchyState!.set(nodeId, { key: nodeKey, states: new Map([[sourceId, state]]) });\r\n stateChanges.push({ ...calculateMergedNodeState([state].values()), nodeKey });\r\n }\r\n handledNodeIds.add(nodeId);\r\n });\r\n\r\n // step 2: walk over old state and remove all state that's not in the new state\r\n const erasedNodeIds = new Set<string | undefined>();\r\n hierarchyState.forEach((entry, nodeId) => {\r\n if (handledNodeIds.has(nodeId)) {\r\n // the node was handled with the new state - nothing to do here\r\n return;\r\n }\r\n\r\n if (!entry.states.has(sourceId)) {\r\n // the node had no state for this source, so it's not affected by this report\r\n return;\r\n }\r\n\r\n using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {\r\n entry.states.delete(sourceId);\r\n });\r\n\r\n // istanbul ignore next\r\n if (entry.states.size === 0) {\r\n // there are no more components holding state for this node\r\n erasedNodeIds.add(nodeId);\r\n }\r\n });\r\n\r\n // step 3: cleanup erased node ids and possibly the whole hierarchy state\r\n for (const nodeId of erasedNodeIds) {\r\n hierarchyState.delete(nodeId);\r\n }\r\n if (hierarchyState.size === 0)\r\n this._hierarchyStates.delete(rulesetId);\r\n\r\n // finally, report\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);\r\n }\r\n}\r\n\r\nfunction calculateMergedNodeState(perComponentStates: IterableIterator<NodeState>): MergedNodeState {\r\n const merged: MergedNodeState = {};\r\n for (const state of perComponentStates) {\r\n if (state.isExpanded)\r\n merged.isExpanded = true;\r\n if (state.instanceFilter) {\r\n if (!merged.instanceFilters)\r\n merged.instanceFilters = [state.instanceFilter];\r\n else if (!merged.instanceFilters.includes(state.instanceFilter))\r\n merged.instanceFilters.push(state.instanceFilter);\r\n }\r\n }\r\n return merged;\r\n}\r\n\r\nclass MergedNodeStateChangeReporter implements IDisposable {\r\n private _entry: NodeStatesEntry;\r\n private _stateBefore: MergedNodeState;\r\n private _outStateChanges: ReportedNodeState[];\r\n public constructor(entry: NodeStatesEntry, outStateChanges: ReportedNodeState[]) {\r\n this._entry = entry;\r\n this._stateBefore = calculateMergedNodeState(this._entry.states.values());\r\n this._outStateChanges = outStateChanges;\r\n }\r\n public dispose() {\r\n const stateAfter = calculateMergedNodeState(this._entry.states.values());\r\n const expandedFlagsDiffer = !!stateAfter.isExpanded !== !!this._stateBefore.isExpanded;\r\n const instanceFiltersDiffer = (stateAfter.instanceFilters?.length ?? 0) !== (this._stateBefore.instanceFilters?.length ?? 0);\r\n if (expandedFlagsDiffer || instanceFiltersDiffer)\r\n this._outStateChanges.push({ ...stateAfter, nodeKey: this._entry.key });\r\n }\r\n}\r\n"]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Core
|
|
3
|
-
*/
|
|
4
|
-
import { IModelConnection } from "@itwin/core-frontend";
|
|
5
|
-
import { NodeKey } from "@itwin/presentation-common";
|
|
6
|
-
import { IpcRequestsHandler } from "./IpcRequestsHandler";
|
|
7
|
-
/**
|
|
8
|
-
* Data structure that describes information used by [[StateTracker]] to identify node.
|
|
9
|
-
* @internal
|
|
10
|
-
*/
|
|
11
|
-
export interface NodeIdentifier {
|
|
12
|
-
id: string;
|
|
13
|
-
key: NodeKey;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
export interface NodeState {
|
|
19
|
-
isExpanded?: boolean;
|
|
20
|
-
instanceFilter?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
|
|
24
|
-
* just the state changes to the backend as soon as component sends in a new hierarchy state.
|
|
25
|
-
*
|
|
26
|
-
* @internal
|
|
27
|
-
*/
|
|
28
|
-
export declare class StateTracker {
|
|
29
|
-
private _hierarchyStates;
|
|
30
|
-
private _ipcRequestsHandler;
|
|
31
|
-
constructor(ipcRequestsHandler: IpcRequestsHandler);
|
|
32
|
-
private updateHierarchyStateIfNeeded;
|
|
33
|
-
onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string): Promise<void>;
|
|
34
|
-
onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{
|
|
35
|
-
node: NodeIdentifier | undefined;
|
|
36
|
-
state: NodeState;
|
|
37
|
-
}>): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=StateTracker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StateTracker.d.ts","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAgBD;;;;;GAKG;AACH,qBAAa,YAAY;IAEvB,OAAO,CAAC,gBAAgB,CAAwD;IAChF,OAAO,CAAC,mBAAmB,CAAqB;gBAEpC,kBAAkB,EAAE,kBAAkB;YAKpC,4BAA4B;IAM7B,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAmB/E,uBAAuB,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;CA+DrL"}
|
|
@@ -1,126 +0,0 @@
|
|
|
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
|
-
/** @packageDocumentation
|
|
6
|
-
* @module Core
|
|
7
|
-
*/
|
|
8
|
-
import { using } from "@itwin/core-bentley";
|
|
9
|
-
/**
|
|
10
|
-
* The tracker stores up-to-date UI state of the hierarchies on the frontend and reports
|
|
11
|
-
* just the state changes to the backend as soon as component sends in a new hierarchy state.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export class StateTracker {
|
|
16
|
-
constructor(ipcRequestsHandler) {
|
|
17
|
-
this._ipcRequestsHandler = ipcRequestsHandler;
|
|
18
|
-
this._hierarchyStates = new Map();
|
|
19
|
-
}
|
|
20
|
-
async updateHierarchyStateIfNeeded(imodelKey, rulesetId, stateChanges) {
|
|
21
|
-
if (stateChanges.length === 0)
|
|
22
|
-
return;
|
|
23
|
-
await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, stateChanges });
|
|
24
|
-
}
|
|
25
|
-
async onHierarchyClosed(imodel, rulesetId, sourceId) {
|
|
26
|
-
const hierarchyState = this._hierarchyStates.get(rulesetId);
|
|
27
|
-
if (!hierarchyState)
|
|
28
|
-
return;
|
|
29
|
-
const stateChanges = [];
|
|
30
|
-
hierarchyState.forEach((entry) => {
|
|
31
|
-
if (!entry.states.has(sourceId)) {
|
|
32
|
-
// the node has no state for this source - nothing to do
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {
|
|
36
|
-
entry.states.delete(sourceId);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);
|
|
40
|
-
}
|
|
41
|
-
async onHierarchyStateChanged(imodel, rulesetId, sourceId, newHierarchyState) {
|
|
42
|
-
let hierarchyState = this._hierarchyStates.get(rulesetId);
|
|
43
|
-
if (!hierarchyState) {
|
|
44
|
-
if (newHierarchyState.length === 0)
|
|
45
|
-
return;
|
|
46
|
-
hierarchyState = new Map();
|
|
47
|
-
this._hierarchyStates.set(rulesetId, hierarchyState);
|
|
48
|
-
}
|
|
49
|
-
const handledNodeIds = new Set();
|
|
50
|
-
const stateChanges = [];
|
|
51
|
-
// step 1: walk over new state and report all changes
|
|
52
|
-
newHierarchyState.forEach(({ node, state }) => {
|
|
53
|
-
const nodeId = node === null || node === void 0 ? void 0 : node.id;
|
|
54
|
-
const nodeKey = node === null || node === void 0 ? void 0 : node.key;
|
|
55
|
-
const existingNodeEntry = hierarchyState.get(nodeId);
|
|
56
|
-
if (existingNodeEntry) {
|
|
57
|
-
using(new MergedNodeStateChangeReporter(existingNodeEntry, stateChanges), (_) => {
|
|
58
|
-
existingNodeEntry.states.set(sourceId, state);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
hierarchyState.set(nodeId, { key: nodeKey, states: new Map([[sourceId, state]]) });
|
|
63
|
-
stateChanges.push({ ...calculateMergedNodeState([state].values()), nodeKey });
|
|
64
|
-
}
|
|
65
|
-
handledNodeIds.add(nodeId);
|
|
66
|
-
});
|
|
67
|
-
// step 2: walk over old state and remove all state that's not in the new state
|
|
68
|
-
const erasedNodeIds = new Set();
|
|
69
|
-
hierarchyState.forEach((entry, nodeId) => {
|
|
70
|
-
if (handledNodeIds.has(nodeId)) {
|
|
71
|
-
// the node was handled with the new state - nothing to do here
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
if (!entry.states.has(sourceId)) {
|
|
75
|
-
// the node had no state for this source, so it's not affected by this report
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {
|
|
79
|
-
entry.states.delete(sourceId);
|
|
80
|
-
});
|
|
81
|
-
// istanbul ignore next
|
|
82
|
-
if (entry.states.size === 0) {
|
|
83
|
-
// there are no more components holding state for this node
|
|
84
|
-
erasedNodeIds.add(nodeId);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
// step 3: cleanup erased node ids and possibly the whole hierarchy state
|
|
88
|
-
for (const nodeId of erasedNodeIds) {
|
|
89
|
-
hierarchyState.delete(nodeId);
|
|
90
|
-
}
|
|
91
|
-
if (hierarchyState.size === 0)
|
|
92
|
-
this._hierarchyStates.delete(rulesetId);
|
|
93
|
-
// finally, report
|
|
94
|
-
await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function calculateMergedNodeState(perComponentStates) {
|
|
98
|
-
const merged = {};
|
|
99
|
-
for (const state of perComponentStates) {
|
|
100
|
-
if (state.isExpanded)
|
|
101
|
-
merged.isExpanded = true;
|
|
102
|
-
if (state.instanceFilter) {
|
|
103
|
-
if (!merged.instanceFilters)
|
|
104
|
-
merged.instanceFilters = [state.instanceFilter];
|
|
105
|
-
else if (!merged.instanceFilters.includes(state.instanceFilter))
|
|
106
|
-
merged.instanceFilters.push(state.instanceFilter);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return merged;
|
|
110
|
-
}
|
|
111
|
-
class MergedNodeStateChangeReporter {
|
|
112
|
-
constructor(entry, outStateChanges) {
|
|
113
|
-
this._entry = entry;
|
|
114
|
-
this._stateBefore = calculateMergedNodeState(this._entry.states.values());
|
|
115
|
-
this._outStateChanges = outStateChanges;
|
|
116
|
-
}
|
|
117
|
-
dispose() {
|
|
118
|
-
var _a, _b, _c, _d;
|
|
119
|
-
const stateAfter = calculateMergedNodeState(this._entry.states.values());
|
|
120
|
-
const expandedFlagsDiffer = !!stateAfter.isExpanded !== !!this._stateBefore.isExpanded;
|
|
121
|
-
const instanceFiltersDiffer = ((_b = (_a = stateAfter.instanceFilters) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) !== ((_d = (_c = this._stateBefore.instanceFilters) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0);
|
|
122
|
-
if (expandedFlagsDiffer || instanceFiltersDiffer)
|
|
123
|
-
this._outStateChanges.push({ ...stateAfter, nodeKey: this._entry.key });
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
//# sourceMappingURL=StateTracker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StateTracker.js","sourceRoot":"","sources":["../../../src/presentation-frontend/StateTracker.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAe,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAoCzD;;;;;GAKG;AACH,MAAM,OAAO,YAAY;IAKvB,YAAY,kBAAsC;QAChD,IAAI,CAAC,mBAAmB,GAAG,kBAAkB,CAAC;QAC9C,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;IACpC,CAAC;IAEO,KAAK,CAAC,4BAA4B,CAAC,SAAiB,EAAE,SAAiB,EAAE,YAAiC;QAChH,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAC3B,OAAO;QACT,MAAM,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,CAAC;IAC9F,CAAC;IAEM,KAAK,CAAC,iBAAiB,CAAC,MAAwB,EAAE,SAAiB,EAAE,QAAgB;QAC1F,MAAM,cAAc,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAA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AC,CAAC;QAC1E,IAAI,CAAC,gBAAgB,GAAG,eAAe,CAAC;IAC1C,CAAC;IACM,OAAO;;QACZ,MAAM,UAAU,GAAG,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACzE,MAAM,mBAAmB,GAAG,CAAC,CAAC,UAAU,CAAC,UAAU,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;QACvF,MAAM,qBAAqB,GAAG,CAAC,MAAA,MAAA,UAAU,CAAC,eAAe,0CAAE,MAAM,mCAAI,CAAC,CAAC,KAAK,CAAC,MAAA,MAAA,IAAI,CAAC,YAAY,CAAC,eAAe,0CAAE,MAAM,mCAAI,CAAC,CAAC,CAAC;QAC7H,IAAI,mBAAmB,IAAI,qBAAqB;YAC9C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5E,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { IDisposable, using } from \"@itwin/core-bentley\";\r\nimport { IModelConnection } from \"@itwin/core-frontend\";\r\nimport { NodeKey } from \"@itwin/presentation-common\";\r\nimport { IpcRequestsHandler } from \"./IpcRequestsHandler\";\r\n\r\n/**\r\n * Data structure that describes information used by [[StateTracker]] to identify node.\r\n * @internal\r\n */\r\nexport interface NodeIdentifier {\r\n id: string;\r\n key: NodeKey;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface NodeState {\r\n isExpanded?: boolean;\r\n instanceFilter?: string;\r\n}\r\n\r\ninterface MergedNodeState {\r\n isExpanded?: boolean;\r\n instanceFilters?: string[];\r\n}\r\n\r\ninterface ReportedNodeState extends MergedNodeState {\r\n nodeKey: NodeKey | undefined;\r\n}\r\n\r\ninterface NodeStatesEntry {\r\n key: NodeKey | undefined;\r\n states: Map<string, NodeState>; // per-component node state\r\n}\r\n\r\n/**\r\n * The tracker stores up-to-date UI state of the hierarchies on the frontend and reports\r\n * just the state changes to the backend as soon as component sends in a new hierarchy state.\r\n *\r\n * @internal\r\n */\r\nexport class StateTracker {\r\n // Ruleset ID => Node ID => Node state info\r\n private _hierarchyStates: Map<string, Map<string | undefined, NodeStatesEntry>>;\r\n private _ipcRequestsHandler: IpcRequestsHandler;\r\n\r\n constructor(ipcRequestsHandler: IpcRequestsHandler) {\r\n this._ipcRequestsHandler = ipcRequestsHandler;\r\n this._hierarchyStates = new Map();\r\n }\r\n\r\n private async updateHierarchyStateIfNeeded(imodelKey: string, rulesetId: string, stateChanges: ReportedNodeState[]) {\r\n if (stateChanges.length === 0)\r\n return;\r\n await this._ipcRequestsHandler.updateHierarchyState({ imodelKey, rulesetId, stateChanges });\r\n }\r\n\r\n public async onHierarchyClosed(imodel: IModelConnection, rulesetId: string, sourceId: string) {\r\n const hierarchyState = this._hierarchyStates.get(rulesetId);\r\n if (!hierarchyState)\r\n return;\r\n\r\n const stateChanges: ReportedNodeState[] = [];\r\n hierarchyState.forEach((entry) => {\r\n if (!entry.states.has(sourceId)) {\r\n // the node has no state for this source - nothing to do\r\n return;\r\n }\r\n using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {\r\n entry.states.delete(sourceId);\r\n });\r\n });\r\n\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);\r\n }\r\n\r\n public async onHierarchyStateChanged(imodel: IModelConnection, rulesetId: string, sourceId: string, newHierarchyState: Array<{ node: NodeIdentifier | undefined, state: NodeState }>) {\r\n let hierarchyState = this._hierarchyStates.get(rulesetId);\r\n if (!hierarchyState) {\r\n if (newHierarchyState.length === 0)\r\n return;\r\n\r\n hierarchyState = new Map();\r\n this._hierarchyStates.set(rulesetId, hierarchyState);\r\n }\r\n\r\n const handledNodeIds = new Set<string | undefined>();\r\n const stateChanges: ReportedNodeState[] = [];\r\n\r\n // step 1: walk over new state and report all changes\r\n newHierarchyState.forEach(({ node, state }) => {\r\n const nodeId = node?.id;\r\n const nodeKey = node?.key;\r\n const existingNodeEntry = hierarchyState!.get(nodeId);\r\n if (existingNodeEntry) {\r\n using(new MergedNodeStateChangeReporter(existingNodeEntry, stateChanges), (_) => {\r\n existingNodeEntry.states.set(sourceId, state);\r\n });\r\n } else {\r\n hierarchyState!.set(nodeId, { key: nodeKey, states: new Map([[sourceId, state]]) });\r\n stateChanges.push({ ...calculateMergedNodeState([state].values()), nodeKey });\r\n }\r\n handledNodeIds.add(nodeId);\r\n });\r\n\r\n // step 2: walk over old state and remove all state that's not in the new state\r\n const erasedNodeIds = new Set<string | undefined>();\r\n hierarchyState.forEach((entry, nodeId) => {\r\n if (handledNodeIds.has(nodeId)) {\r\n // the node was handled with the new state - nothing to do here\r\n return;\r\n }\r\n\r\n if (!entry.states.has(sourceId)) {\r\n // the node had no state for this source, so it's not affected by this report\r\n return;\r\n }\r\n\r\n using(new MergedNodeStateChangeReporter(entry, stateChanges), (_) => {\r\n entry.states.delete(sourceId);\r\n });\r\n\r\n // istanbul ignore next\r\n if (entry.states.size === 0) {\r\n // there are no more components holding state for this node\r\n erasedNodeIds.add(nodeId);\r\n }\r\n });\r\n\r\n // step 3: cleanup erased node ids and possibly the whole hierarchy state\r\n for (const nodeId of erasedNodeIds) {\r\n hierarchyState.delete(nodeId);\r\n }\r\n if (hierarchyState.size === 0)\r\n this._hierarchyStates.delete(rulesetId);\r\n\r\n // finally, report\r\n await this.updateHierarchyStateIfNeeded(imodel.key, rulesetId, stateChanges);\r\n }\r\n}\r\n\r\nfunction calculateMergedNodeState(perComponentStates: IterableIterator<NodeState>): MergedNodeState {\r\n const merged: MergedNodeState = {};\r\n for (const state of perComponentStates) {\r\n if (state.isExpanded)\r\n merged.isExpanded = true;\r\n if (state.instanceFilter) {\r\n if (!merged.instanceFilters)\r\n merged.instanceFilters = [state.instanceFilter];\r\n else if (!merged.instanceFilters.includes(state.instanceFilter))\r\n merged.instanceFilters.push(state.instanceFilter);\r\n }\r\n }\r\n return merged;\r\n}\r\n\r\nclass MergedNodeStateChangeReporter implements IDisposable {\r\n private _entry: NodeStatesEntry;\r\n private _stateBefore: MergedNodeState;\r\n private _outStateChanges: ReportedNodeState[];\r\n public constructor(entry: NodeStatesEntry, outStateChanges: ReportedNodeState[]) {\r\n this._entry = entry;\r\n this._stateBefore = calculateMergedNodeState(this._entry.states.values());\r\n this._outStateChanges = outStateChanges;\r\n }\r\n public dispose() {\r\n const stateAfter = calculateMergedNodeState(this._entry.states.values());\r\n const expandedFlagsDiffer = !!stateAfter.isExpanded !== !!this._stateBefore.isExpanded;\r\n const instanceFiltersDiffer = (stateAfter.instanceFilters?.length ?? 0) !== (this._stateBefore.instanceFilters?.length ?? 0);\r\n if (expandedFlagsDiffer || instanceFiltersDiffer)\r\n this._outStateChanges.push({ ...stateAfter, nodeKey: this._entry.key });\r\n }\r\n}\r\n"]}
|