@itwin/presentation-frontend 4.0.0-dev.10 → 4.0.0-dev.101

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 (138) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
  3. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +47 -47
  4. package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  5. package/lib/cjs/presentation-frontend/Diagnostics.d.ts +14 -14
  6. package/lib/cjs/presentation-frontend/Diagnostics.js +61 -61
  7. package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
  8. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
  9. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +20 -20
  10. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  11. package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +9 -10
  12. package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  13. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +32 -41
  14. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  15. package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +10 -10
  16. package/lib/cjs/presentation-frontend/LocalizationHelper.js +31 -31
  17. package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
  18. package/lib/cjs/presentation-frontend/Presentation.d.ts +73 -75
  19. package/lib/cjs/presentation-frontend/Presentation.d.ts.map +1 -1
  20. package/lib/cjs/presentation-frontend/Presentation.js +159 -162
  21. package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
  22. package/lib/cjs/presentation-frontend/PresentationManager.d.ts +207 -186
  23. package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
  24. package/lib/cjs/presentation-frontend/PresentationManager.js +442 -436
  25. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  26. package/lib/cjs/presentation-frontend/RulesetManager.d.ts +63 -63
  27. package/lib/cjs/presentation-frontend/RulesetManager.js +85 -85
  28. package/lib/cjs/presentation-frontend/RulesetManager.js.map +1 -1
  29. package/lib/cjs/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
  30. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js +195 -195
  31. package/lib/cjs/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  32. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
  33. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  34. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +527 -525
  35. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  36. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
  37. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +290 -293
  38. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  39. package/lib/cjs/presentation-frontend/selection/HiliteRules.json +172 -172
  40. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
  41. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +97 -97
  42. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  43. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
  44. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +9 -9
  45. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  46. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
  47. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +33 -33
  48. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  49. package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
  50. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +108 -108
  51. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  52. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +17 -14
  53. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  54. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +40 -37
  55. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  56. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +139 -139
  57. package/lib/cjs/presentation-frontend/selection/SelectionManager.js +414 -414
  58. package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
  59. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
  60. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +91 -91
  61. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  62. package/lib/cjs/presentation-frontend.d.ts +33 -34
  63. package/lib/cjs/presentation-frontend.d.ts.map +1 -1
  64. package/lib/cjs/presentation-frontend.js +53 -50
  65. package/lib/cjs/presentation-frontend.js.map +1 -1
  66. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
  67. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js +43 -43
  68. package/lib/esm/presentation-frontend/ConnectivityInformationProvider.js.map +1 -1
  69. package/lib/esm/presentation-frontend/Diagnostics.d.ts +14 -14
  70. package/lib/esm/presentation-frontend/Diagnostics.js +56 -56
  71. package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
  72. package/lib/esm/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
  73. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +17 -17
  74. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  75. package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +9 -10
  76. package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts.map +1 -1
  77. package/lib/esm/presentation-frontend/IpcRequestsHandler.js +28 -37
  78. package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  79. package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +10 -10
  80. package/lib/esm/presentation-frontend/LocalizationHelper.js +27 -27
  81. package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
  82. package/lib/esm/presentation-frontend/Presentation.d.ts +73 -75
  83. package/lib/esm/presentation-frontend/Presentation.d.ts.map +1 -1
  84. package/lib/esm/presentation-frontend/Presentation.js +155 -158
  85. package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
  86. package/lib/esm/presentation-frontend/PresentationManager.d.ts +207 -186
  87. package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
  88. package/lib/esm/presentation-frontend/PresentationManager.js +437 -431
  89. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  90. package/lib/esm/presentation-frontend/RulesetManager.d.ts +63 -63
  91. package/lib/esm/presentation-frontend/RulesetManager.js +81 -81
  92. package/lib/esm/presentation-frontend/RulesetManager.js.map +1 -1
  93. package/lib/esm/presentation-frontend/RulesetVariablesManager.d.ts +143 -143
  94. package/lib/esm/presentation-frontend/RulesetVariablesManager.js +191 -191
  95. package/lib/esm/presentation-frontend/RulesetVariablesManager.js.map +1 -1
  96. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
  97. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts.map +1 -1
  98. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +522 -519
  99. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  100. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
  101. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +282 -285
  102. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  103. package/lib/esm/presentation-frontend/selection/HiliteRules.json +172 -172
  104. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
  105. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +93 -93
  106. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  107. package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
  108. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +8 -8
  109. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  110. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
  111. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +29 -29
  112. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  113. package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
  114. package/lib/esm/presentation-frontend/selection/SelectionHandler.js +104 -104
  115. package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  116. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +17 -14
  117. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts.map +1 -1
  118. package/lib/esm/presentation-frontend/selection/SelectionHelper.js +36 -33
  119. package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  120. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +139 -139
  121. package/lib/esm/presentation-frontend/selection/SelectionManager.js +409 -409
  122. package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
  123. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
  124. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +85 -85
  125. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  126. package/lib/esm/presentation-frontend.d.ts +33 -34
  127. package/lib/esm/presentation-frontend.d.ts.map +1 -1
  128. package/lib/esm/presentation-frontend.js +37 -38
  129. package/lib/esm/presentation-frontend.js.map +1 -1
  130. package/package.json +23 -22
  131. package/lib/cjs/presentation-frontend/StateTracker.d.ts +0 -39
  132. package/lib/cjs/presentation-frontend/StateTracker.d.ts.map +0 -1
  133. package/lib/cjs/presentation-frontend/StateTracker.js +0 -130
  134. package/lib/cjs/presentation-frontend/StateTracker.js.map +0 -1
  135. package/lib/esm/presentation-frontend/StateTracker.d.ts +0 -39
  136. package/lib/esm/presentation-frontend/StateTracker.d.ts.map +0 -1
  137. package/lib/esm/presentation-frontend/StateTracker.js +0 -126
  138. package/lib/esm/presentation-frontend/StateTracker.js.map +0 -1
@@ -1,159 +1,156 @@
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 { IModelApp } from "@itwin/core-frontend";
9
- import { PresentationError, PresentationStatus } from "@itwin/presentation-common";
10
- import { FavoritePropertiesManager } from "./favorite-properties/FavoritePropertiesManager";
11
- import { createFavoritePropertiesStorage, DefaultFavoritePropertiesStorageTypes } from "./favorite-properties/FavoritePropertiesStorage";
12
- import { FrontendLocalizationHelper } from "./LocalizationHelper";
13
- import { PresentationManager } from "./PresentationManager";
14
- import { SelectionManager } from "./selection/SelectionManager";
15
- import { SelectionScopesManager } from "./selection/SelectionScopesManager";
16
- let localization;
17
- let presentationManager;
18
- let selectionManager;
19
- let favoritePropertiesManager;
20
- const initializationHandlers = [];
21
- const terminationHandlers = [];
22
- /**
23
- * Static class used to statically set up Presentation library for the frontend.
24
- * Basically what it does is:
25
- * - Create a singleton [[PresentationManager]] instance
26
- * - Create a singleton [[SelectionManager]] instance
27
- * - Create a singleton [[FavoritePropertiesManager]]] instance
28
- *
29
- * @public
30
- */
31
- export class Presentation {
32
- /* istanbul ignore next */
33
- constructor() { }
34
- /**
35
- * Initializes Presentation library for the frontend.
36
- *
37
- * Example:
38
- * ``` ts
39
- * [[include:Presentation.Frontend.Initialization]]
40
- * ```
41
- *
42
- * The method should be called after a call to [IModelApp.startup]($core-frontend).
43
- */
44
- static async initialize(props) {
45
- var _a, _b;
46
- if (!IModelApp.initialized) {
47
- throw new PresentationError(PresentationStatus.NotInitialized, "IModelApp.startup must be called before calling Presentation.initialize");
48
- }
49
- if (!localization) {
50
- localization = IModelApp.localization;
51
- }
52
- if (!presentationManager) {
53
- const managerProps = (_a = props === null || props === void 0 ? void 0 : props.presentation) !== null && _a !== void 0 ? _a : {};
54
- if (!managerProps.activeLocale) {
55
- const languages = Presentation.localization.getLanguageList();
56
- managerProps.activeLocale = (languages.length ? languages[0] : undefined);
57
- }
58
- presentationManager = PresentationManager.create(managerProps);
59
- }
60
- if (!selectionManager) {
61
- selectionManager = new SelectionManager((_b = props === null || props === void 0 ? void 0 : props.selection) !== null && _b !== void 0 ? _b : {
62
- scopes: new SelectionScopesManager({
63
- rpcRequestsHandler: presentationManager.rpcRequestsHandler,
64
- localeProvider: () => this.presentation.activeLocale,
65
- }),
66
- });
67
- }
68
- if (!favoritePropertiesManager) {
69
- favoritePropertiesManager = new FavoritePropertiesManager({
70
- storage: (props === null || props === void 0 ? void 0 : props.favorites) ? props.favorites.storage : createFavoritePropertiesStorage(DefaultFavoritePropertiesStorageTypes.Noop),
71
- });
72
- }
73
- // eslint-disable-next-line @typescript-eslint/unbound-method
74
- presentationManager.onNewiModelConnection = favoritePropertiesManager.initializeConnection.bind(favoritePropertiesManager);
75
- await FrontendLocalizationHelper.registerNamespaces();
76
- for (const handler of initializationHandlers) {
77
- const cleanup = await handler();
78
- if (cleanup)
79
- terminationHandlers.push(cleanup);
80
- }
81
- }
82
- /**
83
- * Terminates Presentation library frontend. This method should be called
84
- * before a call to [IModelApp.shutdown]($core-frontend)
85
- */
86
- static terminate() {
87
- terminationHandlers.forEach((handler) => handler());
88
- terminationHandlers.length = 0;
89
- if (localization)
90
- FrontendLocalizationHelper.unregisterNamespaces();
91
- if (presentationManager)
92
- presentationManager.dispose();
93
- presentationManager = undefined;
94
- if (favoritePropertiesManager)
95
- favoritePropertiesManager.dispose();
96
- favoritePropertiesManager = undefined;
97
- selectionManager = undefined;
98
- localization = undefined;
99
- }
100
- /**
101
- * Registers an additional handler which will be invoked during Presentation library frontend
102
- * initialization.
103
- *
104
- * @internal
105
- */
106
- static registerInitializationHandler(handler) {
107
- initializationHandlers.push(handler);
108
- }
109
- /** The singleton [[PresentationManager]] */
110
- static get presentation() {
111
- if (!presentationManager)
112
- throw new Error("Presentation must be first initialized by calling Presentation.initialize");
113
- return presentationManager;
114
- }
115
- /** @internal */
116
- static setPresentationManager(value) {
117
- if (presentationManager)
118
- presentationManager.dispose();
119
- presentationManager = value;
120
- }
121
- /** The singleton [[SelectionManager]] */
122
- static get selection() {
123
- if (!selectionManager)
124
- throw new Error("Presentation must be first initialized by calling Presentation.initialize");
125
- return selectionManager;
126
- }
127
- /** @internal */
128
- static setSelectionManager(value) {
129
- selectionManager = value;
130
- }
131
- /**
132
- * The singleton [[FavoritePropertiesManager]]
133
- * @public
134
- */
135
- static get favoriteProperties() {
136
- if (!favoritePropertiesManager)
137
- throw new Error("Favorite Properties must be first initialized by calling Presentation.initialize");
138
- return favoritePropertiesManager;
139
- }
140
- /** @internal */
141
- static setFavoritePropertiesManager(value) {
142
- if (favoritePropertiesManager)
143
- favoritePropertiesManager.dispose();
144
- favoritePropertiesManager = value;
145
- }
146
- /**
147
- * The localization manager used by Presentation frontend. Returns the result of `IModelApp.i18n`.
148
- */
149
- static get localization() {
150
- if (!localization)
151
- throw new Error("Presentation must be first initialized by calling Presentation.initialize");
152
- return localization;
153
- }
154
- /** @internal */
155
- static setLocalization(value) {
156
- localization = value;
157
- }
158
- }
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 { IModelApp } from "@itwin/core-frontend";
9
+ import { PresentationError, PresentationStatus } from "@itwin/presentation-common";
10
+ import { FavoritePropertiesManager } from "./favorite-properties/FavoritePropertiesManager";
11
+ import { createFavoritePropertiesStorage, DefaultFavoritePropertiesStorageTypes } from "./favorite-properties/FavoritePropertiesStorage";
12
+ import { FrontendLocalizationHelper } from "./LocalizationHelper";
13
+ import { PresentationManager } from "./PresentationManager";
14
+ import { SelectionManager } from "./selection/SelectionManager";
15
+ import { SelectionScopesManager } from "./selection/SelectionScopesManager";
16
+ let localization;
17
+ let presentationManager;
18
+ let selectionManager;
19
+ let favoritePropertiesManager;
20
+ const initializationHandlers = [];
21
+ const terminationHandlers = [];
22
+ /**
23
+ * Static class used to statically set up Presentation library for the frontend.
24
+ * Basically what it does is:
25
+ * - Create a singleton [[PresentationManager]] instance
26
+ * - Create a singleton [[SelectionManager]] instance
27
+ * - Create a singleton [[FavoritePropertiesManager]]] instance
28
+ *
29
+ * @public
30
+ */
31
+ export class Presentation {
32
+ /* istanbul ignore next */
33
+ constructor() { }
34
+ /**
35
+ * Initializes Presentation library for the frontend.
36
+ *
37
+ * Example:
38
+ * ``` ts
39
+ * [[include:Presentation.Frontend.Initialization]]
40
+ * ```
41
+ *
42
+ * The method should be called after a call to [IModelApp.startup]($core-frontend).
43
+ */
44
+ static async initialize(props) {
45
+ if (!IModelApp.initialized) {
46
+ throw new PresentationError(PresentationStatus.NotInitialized, "IModelApp.startup must be called before calling Presentation.initialize");
47
+ }
48
+ if (!localization) {
49
+ localization = IModelApp.localization;
50
+ }
51
+ if (!presentationManager) {
52
+ const managerProps = props?.presentation ?? {};
53
+ if (!managerProps.activeLocale) {
54
+ const languages = Presentation.localization.getLanguageList();
55
+ managerProps.activeLocale = (languages.length ? languages[0] : undefined);
56
+ }
57
+ presentationManager = PresentationManager.create(managerProps);
58
+ }
59
+ if (!selectionManager) {
60
+ selectionManager = new SelectionManager(props?.selection ?? {
61
+ scopes: new SelectionScopesManager({
62
+ rpcRequestsHandler: presentationManager.rpcRequestsHandler,
63
+ localeProvider: () => this.presentation.activeLocale,
64
+ }),
65
+ });
66
+ }
67
+ if (!favoritePropertiesManager) {
68
+ favoritePropertiesManager = new FavoritePropertiesManager({
69
+ storage: props?.favorites ? props.favorites.storage : createFavoritePropertiesStorage(DefaultFavoritePropertiesStorageTypes.Noop),
70
+ });
71
+ }
72
+ // eslint-disable-next-line @typescript-eslint/unbound-method
73
+ presentationManager.onNewiModelConnection = favoritePropertiesManager.initializeConnection.bind(favoritePropertiesManager);
74
+ await FrontendLocalizationHelper.registerNamespaces();
75
+ for (const handler of initializationHandlers) {
76
+ const cleanup = await handler();
77
+ if (cleanup)
78
+ terminationHandlers.push(cleanup);
79
+ }
80
+ }
81
+ /**
82
+ * Terminates Presentation library frontend. This method should be called
83
+ * before a call to [IModelApp.shutdown]($core-frontend)
84
+ */
85
+ static terminate() {
86
+ terminationHandlers.forEach((handler) => handler());
87
+ terminationHandlers.length = 0;
88
+ if (localization)
89
+ FrontendLocalizationHelper.unregisterNamespaces();
90
+ if (presentationManager)
91
+ presentationManager.dispose();
92
+ presentationManager = undefined;
93
+ if (favoritePropertiesManager)
94
+ favoritePropertiesManager.dispose();
95
+ favoritePropertiesManager = undefined;
96
+ selectionManager = undefined;
97
+ localization = undefined;
98
+ }
99
+ /**
100
+ * Registers an additional handler which will be invoked during Presentation library frontend
101
+ * initialization.
102
+ */
103
+ static registerInitializationHandler(handler) {
104
+ initializationHandlers.push(handler);
105
+ }
106
+ /** The singleton [[PresentationManager]] */
107
+ static get presentation() {
108
+ if (!presentationManager)
109
+ throw new Error("Presentation must be first initialized by calling Presentation.initialize");
110
+ return presentationManager;
111
+ }
112
+ /** @internal */
113
+ static setPresentationManager(value) {
114
+ if (presentationManager)
115
+ presentationManager.dispose();
116
+ presentationManager = value;
117
+ }
118
+ /** The singleton [[SelectionManager]] */
119
+ static get selection() {
120
+ if (!selectionManager)
121
+ throw new Error("Presentation must be first initialized by calling Presentation.initialize");
122
+ return selectionManager;
123
+ }
124
+ /** @internal */
125
+ static setSelectionManager(value) {
126
+ selectionManager = value;
127
+ }
128
+ /**
129
+ * The singleton [[FavoritePropertiesManager]]
130
+ * @public
131
+ */
132
+ static get favoriteProperties() {
133
+ if (!favoritePropertiesManager)
134
+ throw new Error("Favorite Properties must be first initialized by calling Presentation.initialize");
135
+ return favoritePropertiesManager;
136
+ }
137
+ /** @internal */
138
+ static setFavoritePropertiesManager(value) {
139
+ if (favoritePropertiesManager)
140
+ favoritePropertiesManager.dispose();
141
+ favoritePropertiesManager = value;
142
+ }
143
+ /**
144
+ * The localization manager used by Presentation frontend. Returns the result of `IModelApp.i18n`.
145
+ */
146
+ static get localization() {
147
+ if (!localization)
148
+ throw new Error("Presentation must be first initialized by calling Presentation.initialize");
149
+ return localization;
150
+ }
151
+ /** @internal */
152
+ static setLocalization(value) {
153
+ localization = value;
154
+ }
155
+ }
159
156
  //# sourceMappingURL=Presentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-frontend/Presentation.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAkC,MAAM,iDAAiD,CAAC;AAC5H,OAAO,EAAE,+BAA+B,EAAE,qCAAqC,EAAE,MAAM,iDAAiD,CAAC;AACzI,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAA4B,MAAM,uBAAuB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAyB,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,IAAI,YAAsC,CAAC;A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C,IAAI,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,4CAA4C;IACrC,MAAM,KAAK,YAAY;QAC5B,IAAI,CAAC,mBAAmB;YACtB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,sBAAsB,CAAC,KAA0B;QAC7D,IAAI,mBAAmB;YACrB,mBAAmB,CAAC,OAAO,EAAE,CAAC;QAChC,mBAAmB,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,yCAAyC;IAClC,MAAM,KAAK,SAAS;QACzB,IAAI,CAAC,gBAAgB;YACnB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,mBAAmB,CAAC,KAAuB;QACvD,gBAAgB,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACI,MAAM,KAAK,kBAAkB;QAClC,IAAI,CAAC,yBAAyB;YAC5B,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;QACtG,OAAO,yBAAyB,CAAC;IACnC,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,4BAA4B,CAAC,KAAgC;QACzE,IAAI,yBAAyB;YAC3B,yBAAyB,CAAC,OAAO,EAAE,CAAC;QACtC,yBAAyB,GAAG,KAAK,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,YAAY;QAC5B,IAAI,CAAC,YAAY;YACf,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,KAAmB;QAC/C,YAAY,GAAG,KAAK,CAAC;IACvB,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 { IModelApp } from \"@itwin/core-frontend\";\r\nimport { Localization } from \"@itwin/core-common\";\r\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\r\nimport { FavoritePropertiesManager, FavoritePropertiesManagerProps } from \"./favorite-properties/FavoritePropertiesManager\";\r\nimport { createFavoritePropertiesStorage, DefaultFavoritePropertiesStorageTypes } from \"./favorite-properties/FavoritePropertiesStorage\";\r\nimport { FrontendLocalizationHelper } from \"./LocalizationHelper\";\r\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\r\nimport { SelectionManager, SelectionManagerProps } from \"./selection/SelectionManager\";\r\nimport { SelectionScopesManager } from \"./selection/SelectionScopesManager\";\r\n\r\nlet localization: Localization | undefined;\r\nlet presentationManager: PresentationManager | undefined;\r\nlet selectionManager: SelectionManager | undefined;\r\nlet favoritePropertiesManager: FavoritePropertiesManager | undefined;\r\nconst initializationHandlers: Array<() => Promise<(() => void) | void>> = [];\r\nconst terminationHandlers: Array<() => void> = [];\r\n\r\n/**\r\n * Props for initializing [[Presentation]].\r\n * @public\r\n */\r\nexport interface PresentationProps {\r\n /** Props for [[PresentationManager]]. */\r\n presentation?: PresentationManagerProps;\r\n\r\n /** Props for [[SelectionManager]]. */\r\n selection?: SelectionManagerProps;\r\n\r\n /** Props for [[FavoritePropertiesManager]]. */\r\n favorites?: FavoritePropertiesManagerProps;\r\n}\r\n\r\n/**\r\n * Static class used to statically set up Presentation library for the frontend.\r\n * Basically what it does is:\r\n * - Create a singleton [[PresentationManager]] instance\r\n * - Create a singleton [[SelectionManager]] instance\r\n * - Create a singleton [[FavoritePropertiesManager]]] instance\r\n *\r\n * @public\r\n */\r\nexport class Presentation {\r\n\r\n /* istanbul ignore next */\r\n private constructor() { }\r\n\r\n /**\r\n * Initializes Presentation library for the frontend.\r\n *\r\n * Example:\r\n * ``` ts\r\n * [[include:Presentation.Frontend.Initialization]]\r\n * ```\r\n *\r\n * The method should be called after a call to [IModelApp.startup]($core-frontend).\r\n */\r\n public static async initialize(props?: PresentationProps): Promise<void> {\r\n if (!IModelApp.initialized) {\r\n throw new PresentationError(PresentationStatus.NotInitialized,\r\n \"IModelApp.startup must be called before calling Presentation.initialize\");\r\n }\r\n if (!localization) {\r\n localization = IModelApp.localization;\r\n }\r\n if (!presentationManager) {\r\n const managerProps = props?.presentation ?? {};\r\n if (!managerProps.activeLocale) {\r\n const languages = Presentation.localization.getLanguageList();\r\n managerProps.activeLocale = (languages.length ? languages[0] : undefined);\r\n }\r\n presentationManager = PresentationManager.create(managerProps);\r\n }\r\n if (!selectionManager) {\r\n selectionManager = new SelectionManager(props?.selection ?? {\r\n scopes: new SelectionScopesManager({\r\n rpcRequestsHandler: presentationManager.rpcRequestsHandler,\r\n localeProvider: () => this.presentation.activeLocale,\r\n }),\r\n });\r\n }\r\n if (!favoritePropertiesManager) {\r\n favoritePropertiesManager = new FavoritePropertiesManager({\r\n storage: props?.favorites ? props.favorites.storage : createFavoritePropertiesStorage(DefaultFavoritePropertiesStorageTypes.Noop),\r\n });\r\n }\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n presentationManager.onNewiModelConnection = favoritePropertiesManager.initializeConnection.bind(favoritePropertiesManager);\r\n await FrontendLocalizationHelper.registerNamespaces();\r\n for (const handler of initializationHandlers) {\r\n const cleanup = await handler();\r\n if (cleanup)\r\n terminationHandlers.push(cleanup);\r\n }\r\n }\r\n\r\n /**\r\n * Terminates Presentation library frontend. This method should be called\r\n * before a call to [IModelApp.shutdown]($core-frontend)\r\n */\r\n public static terminate(): void {\r\n terminationHandlers.forEach((handler) => handler());\r\n terminationHandlers.length = 0;\r\n\r\n if (localization)\r\n FrontendLocalizationHelper.unregisterNamespaces();\r\n\r\n if (presentationManager)\r\n presentationManager.dispose();\r\n presentationManager = undefined;\r\n\r\n if (favoritePropertiesManager)\r\n favoritePropertiesManager.dispose();\r\n favoritePropertiesManager = undefined;\r\n\r\n selectionManager = undefined;\r\n localization = undefined;\r\n }\r\n\r\n /**\r\n * Registers an additional handler which will be invoked during Presentation library frontend\r\n * initialization.\r\n *\r\n * @internal\r\n */\r\n public static registerInitializationHandler(handler: () => Promise<() => void>): void {\r\n initializationHandlers.push(handler);\r\n }\r\n\r\n /** The singleton [[PresentationManager]] */\r\n public static get presentation(): PresentationManager {\r\n if (!presentationManager)\r\n throw new Error(\"Presentation must be first initialized by calling Presentation.initialize\");\r\n return presentationManager;\r\n }\r\n\r\n /** @internal */\r\n public static setPresentationManager(value: PresentationManager) {\r\n if (presentationManager)\r\n presentationManager.dispose();\r\n presentationManager = value;\r\n }\r\n\r\n /** The singleton [[SelectionManager]] */\r\n public static get selection(): SelectionManager {\r\n if (!selectionManager)\r\n throw new Error(\"Presentation must be first initialized by calling Presentation.initialize\");\r\n return selectionManager;\r\n }\r\n\r\n /** @internal */\r\n public static setSelectionManager(value: SelectionManager) {\r\n selectionManager = value;\r\n }\r\n\r\n /**\r\n * The singleton [[FavoritePropertiesManager]]\r\n * @public\r\n */\r\n public static get favoriteProperties(): FavoritePropertiesManager {\r\n if (!favoritePropertiesManager)\r\n throw new Error(\"Favorite Properties must be first initialized by calling Presentation.initialize\");\r\n return favoritePropertiesManager;\r\n }\r\n\r\n /** @internal */\r\n public static setFavoritePropertiesManager(value: FavoritePropertiesManager) {\r\n if (favoritePropertiesManager)\r\n favoritePropertiesManager.dispose();\r\n favoritePropertiesManager = value;\r\n }\r\n\r\n /**\r\n * The localization manager used by Presentation frontend. Returns the result of `IModelApp.i18n`.\r\n */\r\n public static get localization(): Localization {\r\n if (!localization)\r\n throw new Error(\"Presentation must be first initialized by calling Presentation.initialize\");\r\n return localization;\r\n }\r\n\r\n /** @internal */\r\n public static setLocalization(value: Localization) {\r\n localization = value;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../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;IACT,MAAM,CAAC,4BAA4B,CAAC,KAAgC;QACzE,IAAI,yBAAyB;YAC3B,yBAAyB,CAAC,OAAO,EAAE,CAAC;QACtC,yBAAyB,GAAG,KAAK,CAAC;IACpC,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,YAAY;QAC5B,IAAI,CAAC,YAAY;YACf,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,KAAmB;QAC/C,YAAY,GAAG,KAAK,CAAC;IACvB,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/** @packageDocumentation\n * @module Core\n */\n\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { Localization } from \"@itwin/core-common\";\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\nimport { FavoritePropertiesManager, FavoritePropertiesManagerProps } from \"./favorite-properties/FavoritePropertiesManager\";\nimport { createFavoritePropertiesStorage, DefaultFavoritePropertiesStorageTypes } from \"./favorite-properties/FavoritePropertiesStorage\";\nimport { FrontendLocalizationHelper } from \"./LocalizationHelper\";\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\nimport { SelectionManager, SelectionManagerProps } from \"./selection/SelectionManager\";\nimport { SelectionScopesManager } from \"./selection/SelectionScopesManager\";\n\nlet localization: Localization | undefined;\nlet presentationManager: PresentationManager | undefined;\nlet selectionManager: SelectionManager | undefined;\nlet favoritePropertiesManager: FavoritePropertiesManager | undefined;\nconst initializationHandlers: Array<() => Promise<(() => void) | void>> = [];\nconst terminationHandlers: Array<() => void> = [];\n\n/**\n * Props for initializing [[Presentation]].\n * @public\n */\nexport interface PresentationProps {\n /** Props for [[PresentationManager]]. */\n presentation?: PresentationManagerProps;\n\n /** Props for [[SelectionManager]]. */\n selection?: SelectionManagerProps;\n\n /** Props for [[FavoritePropertiesManager]]. */\n favorites?: FavoritePropertiesManagerProps;\n}\n\n/**\n * Static class used to statically set up Presentation library for the frontend.\n * Basically what it does is:\n * - Create a singleton [[PresentationManager]] instance\n * - Create a singleton [[SelectionManager]] instance\n * - Create a singleton [[FavoritePropertiesManager]]] instance\n *\n * @public\n */\nexport class Presentation {\n\n /* istanbul ignore next */\n private constructor() { }\n\n /**\n * Initializes Presentation library for the frontend.\n *\n * Example:\n * ``` ts\n * [[include:Presentation.Frontend.Initialization]]\n * ```\n *\n * The method should be called after a call to [IModelApp.startup]($core-frontend).\n */\n public static async initialize(props?: PresentationProps): Promise<void> {\n if (!IModelApp.initialized) {\n throw new PresentationError(PresentationStatus.NotInitialized,\n \"IModelApp.startup must be called before calling Presentation.initialize\");\n }\n if (!localization) {\n localization = IModelApp.localization;\n }\n if (!presentationManager) {\n const managerProps = props?.presentation ?? {};\n if (!managerProps.activeLocale) {\n const languages = Presentation.localization.getLanguageList();\n managerProps.activeLocale = (languages.length ? languages[0] : undefined);\n }\n presentationManager = PresentationManager.create(managerProps);\n }\n if (!selectionManager) {\n selectionManager = new SelectionManager(props?.selection ?? {\n scopes: new SelectionScopesManager({\n rpcRequestsHandler: presentationManager.rpcRequestsHandler,\n localeProvider: () => this.presentation.activeLocale,\n }),\n });\n }\n if (!favoritePropertiesManager) {\n favoritePropertiesManager = new FavoritePropertiesManager({\n storage: props?.favorites ? props.favorites.storage : createFavoritePropertiesStorage(DefaultFavoritePropertiesStorageTypes.Noop),\n });\n }\n // eslint-disable-next-line @typescript-eslint/unbound-method\n presentationManager.onNewiModelConnection = favoritePropertiesManager.initializeConnection.bind(favoritePropertiesManager);\n await FrontendLocalizationHelper.registerNamespaces();\n for (const handler of initializationHandlers) {\n const cleanup = await handler();\n if (cleanup)\n terminationHandlers.push(cleanup);\n }\n }\n\n /**\n * Terminates Presentation library frontend. This method should be called\n * before a call to [IModelApp.shutdown]($core-frontend)\n */\n public static terminate(): void {\n terminationHandlers.forEach((handler) => handler());\n terminationHandlers.length = 0;\n\n if (localization)\n FrontendLocalizationHelper.unregisterNamespaces();\n\n if (presentationManager)\n presentationManager.dispose();\n presentationManager = undefined;\n\n if (favoritePropertiesManager)\n favoritePropertiesManager.dispose();\n favoritePropertiesManager = undefined;\n\n selectionManager = undefined;\n localization = undefined;\n }\n\n /**\n * Registers an additional handler which will be invoked during Presentation library frontend\n * initialization.\n */\n public static registerInitializationHandler(handler: () => Promise<() => void>): void {\n initializationHandlers.push(handler);\n }\n\n /** The singleton [[PresentationManager]] */\n public static get presentation(): PresentationManager {\n if (!presentationManager)\n throw new Error(\"Presentation must be first initialized by calling Presentation.initialize\");\n return presentationManager;\n }\n\n /** @internal */\n public static setPresentationManager(value: PresentationManager) {\n if (presentationManager)\n presentationManager.dispose();\n presentationManager = value;\n }\n\n /** The singleton [[SelectionManager]] */\n public static get selection(): SelectionManager {\n if (!selectionManager)\n throw new Error(\"Presentation must be first initialized by calling Presentation.initialize\");\n return selectionManager;\n }\n\n /** @internal */\n public static setSelectionManager(value: SelectionManager) {\n selectionManager = value;\n }\n\n /**\n * The singleton [[FavoritePropertiesManager]]\n * @public\n */\n public static get favoriteProperties(): FavoritePropertiesManager {\n if (!favoritePropertiesManager)\n throw new Error(\"Favorite Properties must be first initialized by calling Presentation.initialize\");\n return favoritePropertiesManager;\n }\n\n /** @internal */\n public static setFavoritePropertiesManager(value: FavoritePropertiesManager) {\n if (favoritePropertiesManager)\n favoritePropertiesManager.dispose();\n favoritePropertiesManager = value;\n }\n\n /**\n * The localization manager used by Presentation frontend. Returns the result of `IModelApp.i18n`.\n */\n public static get localization(): Localization {\n if (!localization)\n throw new Error(\"Presentation must be first initialized by calling Presentation.initialize\");\n return localization;\n }\n\n /** @internal */\n public static setLocalization(value: Localization) {\n localization = value;\n }\n}\n"]}