@itwin/presentation-frontend 3.4.0-dev.9 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/CHANGELOG.md +51 -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 -12
  6. package/lib/cjs/presentation-frontend/Diagnostics.d.ts.map +1 -1
  7. package/lib/cjs/presentation-frontend/Diagnostics.js +61 -59
  8. package/lib/cjs/presentation-frontend/Diagnostics.js.map +1 -1
  9. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
  10. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js +20 -20
  11. package/lib/cjs/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  12. package/lib/cjs/presentation-frontend/IpcRequestsHandler.d.ts +10 -10
  13. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +42 -42
  14. package/lib/cjs/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  15. package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +10 -14
  16. package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
  17. package/lib/cjs/presentation-frontend/LocalizationHelper.js +31 -57
  18. package/lib/cjs/presentation-frontend/LocalizationHelper.js.map +1 -1
  19. package/lib/cjs/presentation-frontend/Presentation.d.ts +75 -75
  20. package/lib/cjs/presentation-frontend/Presentation.js +162 -162
  21. package/lib/cjs/presentation-frontend/Presentation.js.map +1 -1
  22. package/lib/cjs/presentation-frontend/PresentationManager.d.ts +180 -179
  23. package/lib/cjs/presentation-frontend/PresentationManager.d.ts.map +1 -1
  24. package/lib/cjs/presentation-frontend/PresentationManager.js +419 -413
  25. package/lib/cjs/presentation-frontend/PresentationManager.js.map +1 -1
  26. package/lib/cjs/presentation-frontend/RulesetManager.d.ts +60 -60
  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/StateTracker.d.ts +23 -23
  33. package/lib/cjs/presentation-frontend/StateTracker.js +74 -74
  34. package/lib/cjs/presentation-frontend/StateTracker.js.map +1 -1
  35. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
  36. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +525 -525
  37. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  38. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
  39. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +293 -293
  40. package/lib/cjs/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  41. package/lib/cjs/presentation-frontend/selection/HiliteRules.json +172 -172
  42. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
  43. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js +97 -97
  44. package/lib/cjs/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  45. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
  46. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js +9 -9
  47. package/lib/cjs/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  48. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
  49. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js +33 -33
  50. package/lib/cjs/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  51. package/lib/cjs/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
  52. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js +108 -108
  53. package/lib/cjs/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  54. package/lib/cjs/presentation-frontend/selection/SelectionHelper.d.ts +14 -14
  55. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +37 -37
  56. package/lib/cjs/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  57. package/lib/cjs/presentation-frontend/selection/SelectionManager.d.ts +139 -139
  58. package/lib/cjs/presentation-frontend/selection/SelectionManager.js +414 -414
  59. package/lib/cjs/presentation-frontend/selection/SelectionManager.js.map +1 -1
  60. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
  61. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +91 -91
  62. package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  63. package/lib/cjs/presentation-frontend.d.ts +34 -34
  64. package/lib/cjs/presentation-frontend.js +50 -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 -12
  70. package/lib/esm/presentation-frontend/Diagnostics.d.ts.map +1 -1
  71. package/lib/esm/presentation-frontend/Diagnostics.js +56 -54
  72. package/lib/esm/presentation-frontend/Diagnostics.js.map +1 -1
  73. package/lib/esm/presentation-frontend/FrontendLoggerCategory.d.ts +12 -12
  74. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js +17 -17
  75. package/lib/esm/presentation-frontend/FrontendLoggerCategory.js.map +1 -1
  76. package/lib/esm/presentation-frontend/IpcRequestsHandler.d.ts +10 -10
  77. package/lib/esm/presentation-frontend/IpcRequestsHandler.js +38 -38
  78. package/lib/esm/presentation-frontend/IpcRequestsHandler.js.map +1 -1
  79. package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +10 -14
  80. package/lib/esm/presentation-frontend/LocalizationHelper.d.ts.map +1 -1
  81. package/lib/esm/presentation-frontend/LocalizationHelper.js +27 -53
  82. package/lib/esm/presentation-frontend/LocalizationHelper.js.map +1 -1
  83. package/lib/esm/presentation-frontend/Presentation.d.ts +75 -75
  84. package/lib/esm/presentation-frontend/Presentation.js +158 -158
  85. package/lib/esm/presentation-frontend/Presentation.js.map +1 -1
  86. package/lib/esm/presentation-frontend/PresentationManager.d.ts +180 -179
  87. package/lib/esm/presentation-frontend/PresentationManager.d.ts.map +1 -1
  88. package/lib/esm/presentation-frontend/PresentationManager.js +414 -408
  89. package/lib/esm/presentation-frontend/PresentationManager.js.map +1 -1
  90. package/lib/esm/presentation-frontend/RulesetManager.d.ts +60 -60
  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/StateTracker.d.ts +23 -23
  97. package/lib/esm/presentation-frontend/StateTracker.js +70 -70
  98. package/lib/esm/presentation-frontend/StateTracker.js.map +1 -1
  99. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.d.ts +132 -132
  100. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js +519 -519
  101. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesManager.js.map +1 -1
  102. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.d.ts +111 -111
  103. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js +285 -285
  104. package/lib/esm/presentation-frontend/favorite-properties/FavoritePropertiesStorage.js.map +1 -1
  105. package/lib/esm/presentation-frontend/selection/HiliteRules.json +172 -172
  106. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.d.ts +52 -52
  107. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js +93 -93
  108. package/lib/esm/presentation-frontend/selection/HiliteSetProvider.js.map +1 -1
  109. package/lib/esm/presentation-frontend/selection/ISelectionProvider.d.ts +19 -19
  110. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js +8 -8
  111. package/lib/esm/presentation-frontend/selection/ISelectionProvider.js.map +1 -1
  112. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.d.ts +52 -52
  113. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js +29 -29
  114. package/lib/esm/presentation-frontend/selection/SelectionChangeEvent.js.map +1 -1
  115. package/lib/esm/presentation-frontend/selection/SelectionHandler.d.ts +103 -103
  116. package/lib/esm/presentation-frontend/selection/SelectionHandler.js +104 -104
  117. package/lib/esm/presentation-frontend/selection/SelectionHandler.js.map +1 -1
  118. package/lib/esm/presentation-frontend/selection/SelectionHelper.d.ts +14 -14
  119. package/lib/esm/presentation-frontend/selection/SelectionHelper.js +33 -33
  120. package/lib/esm/presentation-frontend/selection/SelectionHelper.js.map +1 -1
  121. package/lib/esm/presentation-frontend/selection/SelectionManager.d.ts +139 -139
  122. package/lib/esm/presentation-frontend/selection/SelectionManager.js +409 -409
  123. package/lib/esm/presentation-frontend/selection/SelectionManager.js.map +1 -1
  124. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.d.ts +59 -59
  125. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +85 -85
  126. package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js.map +1 -1
  127. package/lib/esm/presentation-frontend.d.ts +34 -34
  128. package/lib/esm/presentation-frontend.js +38 -38
  129. package/lib/esm/presentation-frontend.js.map +1 -1
  130. package/package.json +15 -15
@@ -1,159 +1,159 @@
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 { LocalizationHelper } 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 LocalizationHelper.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
- LocalizationHelper.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
+ 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
+ }
159
159
  //# 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,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,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;AAC3C,IAAI,mBAAoD,CAAC;AACzD,IAAI,gBAA8C,CAAC;AACnD,IAAI,yBAAgE,CAAC;AACrE,MAAM,sBAAsB,GAA8C,EAAE,CAAC;AAC7E,MAAM,mBAAmB,GAAsB,EAAE,CAAC;AAiBlD;;;;;;;;GAQG;AACH,MAAM,OAAO,YAAY;IAEvB,0BAA0B;IAC1B,gBAAwB,CAAC;IAEzB;;;;;;;;;OASG;IACI,MA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mB;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 { LocalizationHelper } 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 LocalizationHelper.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 LocalizationHelper.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":["../../../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,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,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 * @internal\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"]}