@itwin/presentation-frontend 4.0.0-dev.52 → 4.0.0-dev.55
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/lib/cjs/presentation-frontend/ConnectivityInformationProvider.d.ts +29 -29
- package/lib/cjs/presentation-frontend/ConnectivityInformationProvider.js +47 -47
- 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 +10 -10
- package/lib/cjs/presentation-frontend/IpcRequestsHandler.js +41 -41
- package/lib/cjs/presentation-frontend/LocalizationHelper.d.ts +10 -10
- package/lib/cjs/presentation-frontend/LocalizationHelper.js +31 -31
- package/lib/cjs/presentation-frontend/Presentation.d.ts +73 -73
- package/lib/cjs/presentation-frontend/Presentation.js +159 -159
- package/lib/cjs/presentation-frontend/PresentationManager.d.ts +205 -205
- package/lib/cjs/presentation-frontend/PresentationManager.js +438 -438
- 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/StateTracker.d.ts +38 -38
- package/lib/cjs/presentation-frontend/StateTracker.js +128 -128
- 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 +519 -519
- 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 -290
- 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 -17
- package/lib/cjs/presentation-frontend/selection/SelectionHelper.js +40 -40
- 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/SelectionScopesManager.d.ts +59 -59
- package/lib/cjs/presentation-frontend/selection/SelectionScopesManager.js +91 -91
- package/lib/cjs/presentation-frontend.d.ts +34 -34
- package/lib/cjs/presentation-frontend.js +54 -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/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 +10 -10
- package/lib/esm/presentation-frontend/IpcRequestsHandler.js +37 -37
- package/lib/esm/presentation-frontend/LocalizationHelper.d.ts +10 -10
- package/lib/esm/presentation-frontend/LocalizationHelper.js +27 -27
- package/lib/esm/presentation-frontend/Presentation.d.ts +73 -73
- package/lib/esm/presentation-frontend/Presentation.js +155 -155
- package/lib/esm/presentation-frontend/PresentationManager.d.ts +205 -205
- package/lib/esm/presentation-frontend/PresentationManager.js +433 -433
- 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/StateTracker.d.ts +38 -38
- package/lib/esm/presentation-frontend/StateTracker.js +124 -124
- 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 +514 -513
- 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 -282
- 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 -17
- package/lib/esm/presentation-frontend/selection/SelectionHelper.js +36 -36
- 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/SelectionScopesManager.d.ts +59 -59
- package/lib/esm/presentation-frontend/selection/SelectionScopesManager.js +85 -85
- package/lib/esm/presentation-frontend.d.ts +34 -34
- package/lib/esm/presentation-frontend.js +38 -38
- package/package.json +15 -15
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module Core
|
|
3
|
-
*/
|
|
4
|
-
import { Localization } from "@itwin/core-common";
|
|
5
|
-
import { FavoritePropertiesManager, FavoritePropertiesManagerProps } from "./favorite-properties/FavoritePropertiesManager";
|
|
6
|
-
import { PresentationManager, PresentationManagerProps } from "./PresentationManager";
|
|
7
|
-
import { SelectionManager, SelectionManagerProps } from "./selection/SelectionManager";
|
|
8
|
-
/**
|
|
9
|
-
* Props for initializing [[Presentation]].
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export interface PresentationProps {
|
|
13
|
-
/** Props for [[PresentationManager]]. */
|
|
14
|
-
presentation?: PresentationManagerProps;
|
|
15
|
-
/** Props for [[SelectionManager]]. */
|
|
16
|
-
selection?: SelectionManagerProps;
|
|
17
|
-
/** Props for [[FavoritePropertiesManager]]. */
|
|
18
|
-
favorites?: FavoritePropertiesManagerProps;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Static class used to statically set up Presentation library for the frontend.
|
|
22
|
-
* Basically what it does is:
|
|
23
|
-
* - Create a singleton [[PresentationManager]] instance
|
|
24
|
-
* - Create a singleton [[SelectionManager]] instance
|
|
25
|
-
* - Create a singleton [[FavoritePropertiesManager]]] instance
|
|
26
|
-
*
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export declare class Presentation {
|
|
30
|
-
private constructor();
|
|
31
|
-
/**
|
|
32
|
-
* Initializes Presentation library for the frontend.
|
|
33
|
-
*
|
|
34
|
-
* Example:
|
|
35
|
-
* ``` ts
|
|
36
|
-
* [[include:Presentation.Frontend.Initialization]]
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* The method should be called after a call to [IModelApp.startup]($core-frontend).
|
|
40
|
-
*/
|
|
41
|
-
static initialize(props?: PresentationProps): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Terminates Presentation library frontend. This method should be called
|
|
44
|
-
* before a call to [IModelApp.shutdown]($core-frontend)
|
|
45
|
-
*/
|
|
46
|
-
static terminate(): void;
|
|
47
|
-
/**
|
|
48
|
-
* Registers an additional handler which will be invoked during Presentation library frontend
|
|
49
|
-
* initialization.
|
|
50
|
-
*/
|
|
51
|
-
static registerInitializationHandler(handler: () => Promise<() => void>): void;
|
|
52
|
-
/** The singleton [[PresentationManager]] */
|
|
53
|
-
static get presentation(): PresentationManager;
|
|
54
|
-
/** @internal */
|
|
55
|
-
static setPresentationManager(value: PresentationManager): void;
|
|
56
|
-
/** The singleton [[SelectionManager]] */
|
|
57
|
-
static get selection(): SelectionManager;
|
|
58
|
-
/** @internal */
|
|
59
|
-
static setSelectionManager(value: SelectionManager): void;
|
|
60
|
-
/**
|
|
61
|
-
* The singleton [[FavoritePropertiesManager]]
|
|
62
|
-
* @public
|
|
63
|
-
*/
|
|
64
|
-
static get favoriteProperties(): FavoritePropertiesManager;
|
|
65
|
-
/** @internal */
|
|
66
|
-
static setFavoritePropertiesManager(value: FavoritePropertiesManager): void;
|
|
67
|
-
/**
|
|
68
|
-
* The localization manager used by Presentation frontend. Returns the result of `IModelApp.i18n`.
|
|
69
|
-
*/
|
|
70
|
-
static get localization(): Localization;
|
|
71
|
-
/** @internal */
|
|
72
|
-
static setLocalization(value: Localization): void;
|
|
73
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Core
|
|
3
|
+
*/
|
|
4
|
+
import { Localization } from "@itwin/core-common";
|
|
5
|
+
import { FavoritePropertiesManager, FavoritePropertiesManagerProps } from "./favorite-properties/FavoritePropertiesManager";
|
|
6
|
+
import { PresentationManager, PresentationManagerProps } from "./PresentationManager";
|
|
7
|
+
import { SelectionManager, SelectionManagerProps } from "./selection/SelectionManager";
|
|
8
|
+
/**
|
|
9
|
+
* Props for initializing [[Presentation]].
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface PresentationProps {
|
|
13
|
+
/** Props for [[PresentationManager]]. */
|
|
14
|
+
presentation?: PresentationManagerProps;
|
|
15
|
+
/** Props for [[SelectionManager]]. */
|
|
16
|
+
selection?: SelectionManagerProps;
|
|
17
|
+
/** Props for [[FavoritePropertiesManager]]. */
|
|
18
|
+
favorites?: FavoritePropertiesManagerProps;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Static class used to statically set up Presentation library for the frontend.
|
|
22
|
+
* Basically what it does is:
|
|
23
|
+
* - Create a singleton [[PresentationManager]] instance
|
|
24
|
+
* - Create a singleton [[SelectionManager]] instance
|
|
25
|
+
* - Create a singleton [[FavoritePropertiesManager]]] instance
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare class Presentation {
|
|
30
|
+
private constructor();
|
|
31
|
+
/**
|
|
32
|
+
* Initializes Presentation library for the frontend.
|
|
33
|
+
*
|
|
34
|
+
* Example:
|
|
35
|
+
* ``` ts
|
|
36
|
+
* [[include:Presentation.Frontend.Initialization]]
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* The method should be called after a call to [IModelApp.startup]($core-frontend).
|
|
40
|
+
*/
|
|
41
|
+
static initialize(props?: PresentationProps): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Terminates Presentation library frontend. This method should be called
|
|
44
|
+
* before a call to [IModelApp.shutdown]($core-frontend)
|
|
45
|
+
*/
|
|
46
|
+
static terminate(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Registers an additional handler which will be invoked during Presentation library frontend
|
|
49
|
+
* initialization.
|
|
50
|
+
*/
|
|
51
|
+
static registerInitializationHandler(handler: () => Promise<() => void>): void;
|
|
52
|
+
/** The singleton [[PresentationManager]] */
|
|
53
|
+
static get presentation(): PresentationManager;
|
|
54
|
+
/** @internal */
|
|
55
|
+
static setPresentationManager(value: PresentationManager): void;
|
|
56
|
+
/** The singleton [[SelectionManager]] */
|
|
57
|
+
static get selection(): SelectionManager;
|
|
58
|
+
/** @internal */
|
|
59
|
+
static setSelectionManager(value: SelectionManager): void;
|
|
60
|
+
/**
|
|
61
|
+
* The singleton [[FavoritePropertiesManager]]
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
static get favoriteProperties(): FavoritePropertiesManager;
|
|
65
|
+
/** @internal */
|
|
66
|
+
static setFavoritePropertiesManager(value: FavoritePropertiesManager): void;
|
|
67
|
+
/**
|
|
68
|
+
* The localization manager used by Presentation frontend. Returns the result of `IModelApp.i18n`.
|
|
69
|
+
*/
|
|
70
|
+
static get localization(): Localization;
|
|
71
|
+
/** @internal */
|
|
72
|
+
static setLocalization(value: Localization): void;
|
|
73
|
+
}
|
|
74
74
|
//# sourceMappingURL=Presentation.d.ts.map
|
|
@@ -1,160 +1,160 @@
|
|
|
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.Presentation = void 0;
|
|
11
|
-
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
-
const presentation_common_1 = require("@itwin/presentation-common");
|
|
13
|
-
const FavoritePropertiesManager_1 = require("./favorite-properties/FavoritePropertiesManager");
|
|
14
|
-
const FavoritePropertiesStorage_1 = require("./favorite-properties/FavoritePropertiesStorage");
|
|
15
|
-
const LocalizationHelper_1 = require("./LocalizationHelper");
|
|
16
|
-
const PresentationManager_1 = require("./PresentationManager");
|
|
17
|
-
const SelectionManager_1 = require("./selection/SelectionManager");
|
|
18
|
-
const SelectionScopesManager_1 = require("./selection/SelectionScopesManager");
|
|
19
|
-
let localization;
|
|
20
|
-
let presentationManager;
|
|
21
|
-
let selectionManager;
|
|
22
|
-
let favoritePropertiesManager;
|
|
23
|
-
const initializationHandlers = [];
|
|
24
|
-
const terminationHandlers = [];
|
|
25
|
-
/**
|
|
26
|
-
* Static class used to statically set up Presentation library for the frontend.
|
|
27
|
-
* Basically what it does is:
|
|
28
|
-
* - Create a singleton [[PresentationManager]] instance
|
|
29
|
-
* - Create a singleton [[SelectionManager]] instance
|
|
30
|
-
* - Create a singleton [[FavoritePropertiesManager]]] instance
|
|
31
|
-
*
|
|
32
|
-
* @public
|
|
33
|
-
*/
|
|
34
|
-
class Presentation {
|
|
35
|
-
/* istanbul ignore next */
|
|
36
|
-
constructor() { }
|
|
37
|
-
/**
|
|
38
|
-
* Initializes Presentation library for the frontend.
|
|
39
|
-
*
|
|
40
|
-
* Example:
|
|
41
|
-
* ``` ts
|
|
42
|
-
* [[include:Presentation.Frontend.Initialization]]
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* The method should be called after a call to [IModelApp.startup]($core-frontend).
|
|
46
|
-
*/
|
|
47
|
-
static async initialize(props) {
|
|
48
|
-
if (!core_frontend_1.IModelApp.initialized) {
|
|
49
|
-
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.NotInitialized, "IModelApp.startup must be called before calling Presentation.initialize");
|
|
50
|
-
}
|
|
51
|
-
if (!localization) {
|
|
52
|
-
localization = core_frontend_1.IModelApp.localization;
|
|
53
|
-
}
|
|
54
|
-
if (!presentationManager) {
|
|
55
|
-
const managerProps = props?.presentation ?? {};
|
|
56
|
-
if (!managerProps.activeLocale) {
|
|
57
|
-
const languages = Presentation.localization.getLanguageList();
|
|
58
|
-
managerProps.activeLocale = (languages.length ? languages[0] : undefined);
|
|
59
|
-
}
|
|
60
|
-
presentationManager = PresentationManager_1.PresentationManager.create(managerProps);
|
|
61
|
-
}
|
|
62
|
-
if (!selectionManager) {
|
|
63
|
-
selectionManager = new SelectionManager_1.SelectionManager(props?.selection ?? {
|
|
64
|
-
scopes: new SelectionScopesManager_1.SelectionScopesManager({
|
|
65
|
-
rpcRequestsHandler: presentationManager.rpcRequestsHandler,
|
|
66
|
-
localeProvider: () => this.presentation.activeLocale,
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (!favoritePropertiesManager) {
|
|
71
|
-
favoritePropertiesManager = new FavoritePropertiesManager_1.FavoritePropertiesManager({
|
|
72
|
-
storage: props?.favorites ? props.favorites.storage : (0, FavoritePropertiesStorage_1.createFavoritePropertiesStorage)(FavoritePropertiesStorage_1.DefaultFavoritePropertiesStorageTypes.Noop),
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
76
|
-
presentationManager.onNewiModelConnection = favoritePropertiesManager.initializeConnection.bind(favoritePropertiesManager);
|
|
77
|
-
await LocalizationHelper_1.FrontendLocalizationHelper.registerNamespaces();
|
|
78
|
-
for (const handler of initializationHandlers) {
|
|
79
|
-
const cleanup = await handler();
|
|
80
|
-
if (cleanup)
|
|
81
|
-
terminationHandlers.push(cleanup);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Terminates Presentation library frontend. This method should be called
|
|
86
|
-
* before a call to [IModelApp.shutdown]($core-frontend)
|
|
87
|
-
*/
|
|
88
|
-
static terminate() {
|
|
89
|
-
terminationHandlers.forEach((handler) => handler());
|
|
90
|
-
terminationHandlers.length = 0;
|
|
91
|
-
if (localization)
|
|
92
|
-
LocalizationHelper_1.FrontendLocalizationHelper.unregisterNamespaces();
|
|
93
|
-
if (presentationManager)
|
|
94
|
-
presentationManager.dispose();
|
|
95
|
-
presentationManager = undefined;
|
|
96
|
-
if (favoritePropertiesManager)
|
|
97
|
-
favoritePropertiesManager.dispose();
|
|
98
|
-
favoritePropertiesManager = undefined;
|
|
99
|
-
selectionManager = undefined;
|
|
100
|
-
localization = undefined;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Registers an additional handler which will be invoked during Presentation library frontend
|
|
104
|
-
* initialization.
|
|
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
|
-
exports.Presentation = Presentation;
|
|
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.Presentation = void 0;
|
|
11
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
+
const presentation_common_1 = require("@itwin/presentation-common");
|
|
13
|
+
const FavoritePropertiesManager_1 = require("./favorite-properties/FavoritePropertiesManager");
|
|
14
|
+
const FavoritePropertiesStorage_1 = require("./favorite-properties/FavoritePropertiesStorage");
|
|
15
|
+
const LocalizationHelper_1 = require("./LocalizationHelper");
|
|
16
|
+
const PresentationManager_1 = require("./PresentationManager");
|
|
17
|
+
const SelectionManager_1 = require("./selection/SelectionManager");
|
|
18
|
+
const SelectionScopesManager_1 = require("./selection/SelectionScopesManager");
|
|
19
|
+
let localization;
|
|
20
|
+
let presentationManager;
|
|
21
|
+
let selectionManager;
|
|
22
|
+
let favoritePropertiesManager;
|
|
23
|
+
const initializationHandlers = [];
|
|
24
|
+
const terminationHandlers = [];
|
|
25
|
+
/**
|
|
26
|
+
* Static class used to statically set up Presentation library for the frontend.
|
|
27
|
+
* Basically what it does is:
|
|
28
|
+
* - Create a singleton [[PresentationManager]] instance
|
|
29
|
+
* - Create a singleton [[SelectionManager]] instance
|
|
30
|
+
* - Create a singleton [[FavoritePropertiesManager]]] instance
|
|
31
|
+
*
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
class Presentation {
|
|
35
|
+
/* istanbul ignore next */
|
|
36
|
+
constructor() { }
|
|
37
|
+
/**
|
|
38
|
+
* Initializes Presentation library for the frontend.
|
|
39
|
+
*
|
|
40
|
+
* Example:
|
|
41
|
+
* ``` ts
|
|
42
|
+
* [[include:Presentation.Frontend.Initialization]]
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* The method should be called after a call to [IModelApp.startup]($core-frontend).
|
|
46
|
+
*/
|
|
47
|
+
static async initialize(props) {
|
|
48
|
+
if (!core_frontend_1.IModelApp.initialized) {
|
|
49
|
+
throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.NotInitialized, "IModelApp.startup must be called before calling Presentation.initialize");
|
|
50
|
+
}
|
|
51
|
+
if (!localization) {
|
|
52
|
+
localization = core_frontend_1.IModelApp.localization;
|
|
53
|
+
}
|
|
54
|
+
if (!presentationManager) {
|
|
55
|
+
const managerProps = props?.presentation ?? {};
|
|
56
|
+
if (!managerProps.activeLocale) {
|
|
57
|
+
const languages = Presentation.localization.getLanguageList();
|
|
58
|
+
managerProps.activeLocale = (languages.length ? languages[0] : undefined);
|
|
59
|
+
}
|
|
60
|
+
presentationManager = PresentationManager_1.PresentationManager.create(managerProps);
|
|
61
|
+
}
|
|
62
|
+
if (!selectionManager) {
|
|
63
|
+
selectionManager = new SelectionManager_1.SelectionManager(props?.selection ?? {
|
|
64
|
+
scopes: new SelectionScopesManager_1.SelectionScopesManager({
|
|
65
|
+
rpcRequestsHandler: presentationManager.rpcRequestsHandler,
|
|
66
|
+
localeProvider: () => this.presentation.activeLocale,
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (!favoritePropertiesManager) {
|
|
71
|
+
favoritePropertiesManager = new FavoritePropertiesManager_1.FavoritePropertiesManager({
|
|
72
|
+
storage: props?.favorites ? props.favorites.storage : (0, FavoritePropertiesStorage_1.createFavoritePropertiesStorage)(FavoritePropertiesStorage_1.DefaultFavoritePropertiesStorageTypes.Noop),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
76
|
+
presentationManager.onNewiModelConnection = favoritePropertiesManager.initializeConnection.bind(favoritePropertiesManager);
|
|
77
|
+
await LocalizationHelper_1.FrontendLocalizationHelper.registerNamespaces();
|
|
78
|
+
for (const handler of initializationHandlers) {
|
|
79
|
+
const cleanup = await handler();
|
|
80
|
+
if (cleanup)
|
|
81
|
+
terminationHandlers.push(cleanup);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Terminates Presentation library frontend. This method should be called
|
|
86
|
+
* before a call to [IModelApp.shutdown]($core-frontend)
|
|
87
|
+
*/
|
|
88
|
+
static terminate() {
|
|
89
|
+
terminationHandlers.forEach((handler) => handler());
|
|
90
|
+
terminationHandlers.length = 0;
|
|
91
|
+
if (localization)
|
|
92
|
+
LocalizationHelper_1.FrontendLocalizationHelper.unregisterNamespaces();
|
|
93
|
+
if (presentationManager)
|
|
94
|
+
presentationManager.dispose();
|
|
95
|
+
presentationManager = undefined;
|
|
96
|
+
if (favoritePropertiesManager)
|
|
97
|
+
favoritePropertiesManager.dispose();
|
|
98
|
+
favoritePropertiesManager = undefined;
|
|
99
|
+
selectionManager = undefined;
|
|
100
|
+
localization = undefined;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Registers an additional handler which will be invoked during Presentation library frontend
|
|
104
|
+
* initialization.
|
|
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
|
+
exports.Presentation = Presentation;
|
|
160
160
|
//# sourceMappingURL=Presentation.js.map
|