@itwin/presentation-backend 5.0.0-dev.7 → 5.0.0-dev.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +31 -4
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +161 -57
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +2 -2
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +3 -1
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +19 -15
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +1 -4
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +4 -68
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +56 -103
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +3 -3
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +20 -20
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +9 -9
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +74 -84
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +8 -6
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.js +2 -1
- package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +2 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +2 -4
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +33 -42
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +2 -3
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js +30 -26
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +1 -2
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/package.json +18 -17
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
9
|
-
var _a;
|
|
10
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
10
|
exports.Presentation = void 0;
|
|
12
11
|
const core_backend_1 = require("@itwin/core-backend");
|
|
@@ -29,6 +28,12 @@ const TemporaryStorage_1 = require("./TemporaryStorage");
|
|
|
29
28
|
* @public
|
|
30
29
|
*/
|
|
31
30
|
class Presentation {
|
|
31
|
+
static _initProps;
|
|
32
|
+
static _clientsStorage;
|
|
33
|
+
static _disposeIpcHandler;
|
|
34
|
+
static _shutdownListener;
|
|
35
|
+
static _disposeIModelOpenedListener;
|
|
36
|
+
static _rpcImpl;
|
|
32
37
|
/* istanbul ignore next */
|
|
33
38
|
constructor() { }
|
|
34
39
|
/** Properties used to initialize the presentation framework */
|
|
@@ -46,7 +51,7 @@ class Presentation {
|
|
|
46
51
|
*/
|
|
47
52
|
static initialize(props) {
|
|
48
53
|
this._initProps = props || {};
|
|
49
|
-
this._shutdownListener = core_backend_1.IModelHost.onBeforeShutdown.addListener(() =>
|
|
54
|
+
this._shutdownListener = core_backend_1.IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());
|
|
50
55
|
this._rpcImpl = new PresentationRpcImpl_1.PresentationRpcImpl({
|
|
51
56
|
requestTimeout: this._initProps.requestTimeout,
|
|
52
57
|
});
|
|
@@ -76,7 +81,7 @@ class Presentation {
|
|
|
76
81
|
*/
|
|
77
82
|
static terminate() {
|
|
78
83
|
if (this._clientsStorage) {
|
|
79
|
-
this._clientsStorage.dispose();
|
|
84
|
+
this._clientsStorage[Symbol.dispose]();
|
|
80
85
|
this._clientsStorage = undefined;
|
|
81
86
|
}
|
|
82
87
|
if (this._disposeIModelOpenedListener) {
|
|
@@ -89,7 +94,7 @@ class Presentation {
|
|
|
89
94
|
}
|
|
90
95
|
core_common_1.RpcManager.unregisterImpl(presentation_common_1.PresentationRpcInterface);
|
|
91
96
|
if (this._rpcImpl) {
|
|
92
|
-
this._rpcImpl.dispose();
|
|
97
|
+
this._rpcImpl[Symbol.dispose]();
|
|
93
98
|
this._rpcImpl = undefined;
|
|
94
99
|
}
|
|
95
100
|
if (this._disposeIpcHandler) {
|
|
@@ -98,15 +103,15 @@ class Presentation {
|
|
|
98
103
|
this._initProps = undefined;
|
|
99
104
|
}
|
|
100
105
|
static createClientManager(clientId, onManagerUsed) {
|
|
101
|
-
const manager =
|
|
102
|
-
?
|
|
103
|
-
: new PresentationManager_1.PresentationManager({ ...
|
|
106
|
+
const manager = Presentation._initProps && Presentation._initProps.clientManagerFactory
|
|
107
|
+
? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)
|
|
108
|
+
: new PresentationManager_1.PresentationManager({ ...Presentation._initProps, id: clientId });
|
|
104
109
|
manager.setOnManagerUsedHandler(onManagerUsed);
|
|
105
110
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage.values.length}.`);
|
|
106
111
|
return { manager };
|
|
107
112
|
}
|
|
108
113
|
static disposeClientManager(_id, storeItem) {
|
|
109
|
-
storeItem.manager.dispose();
|
|
114
|
+
storeItem.manager[Symbol.dispose]();
|
|
110
115
|
}
|
|
111
116
|
/**
|
|
112
117
|
* Get an instance of [[PresentationManager]] for specific client
|
|
@@ -128,13 +133,12 @@ class Presentation {
|
|
|
128
133
|
}
|
|
129
134
|
return this._rpcImpl.requestTimeout;
|
|
130
135
|
}
|
|
136
|
+
static onIModelOpened = (imodel) => {
|
|
137
|
+
const manager = this.getManager();
|
|
138
|
+
const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
140
|
+
manager.getNativePlatform().forceLoadSchemas(imodelAddon);
|
|
141
|
+
};
|
|
131
142
|
}
|
|
132
143
|
exports.Presentation = Presentation;
|
|
133
|
-
_a = Presentation;
|
|
134
|
-
Presentation.onIModelOpened = (imodel) => {
|
|
135
|
-
const manager = _a.getManager();
|
|
136
|
-
const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
138
|
-
manager.getNativePlatform().forceLoadSchemas(imodelAddon);
|
|
139
|
-
};
|
|
140
144
|
//# sourceMappingURL=Presentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":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AAM,CAAC,iBAAiB;QAC7B,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,cAAc,EAAE,2EAA2E,CAAC,CAAC;QAC9I,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IACtC,CAAC;;AA9HH,oCAsIC;;AANgB,2BAAc,GAAG,CAAC,MAAmB,EAAE,EAAE;IACtD,MAAM,OAAO,GAAG,EAAI,CAAC,UAAU,EAAE,CAAC;IAClC,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACvE,mEAAmE;IACnE,OAAO,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;AAC5D,CAAC,AAL4B,CAK3B","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 { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\r\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\r\nimport { RpcManager } from \"@itwin/core-common\";\r\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler\";\r\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\r\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl\";\r\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage\";\r\n\r\n/**\r\n * Properties that can be used to configure [[Presentation]] API.\r\n * @public\r\n */\r\nexport interface PresentationProps extends Omit<PresentationManagerProps, \"enableSchemasPreload\"> {\r\n /**\r\n * Time in milliseconds after which the request will timeout.\r\n */\r\n requestTimeout?: number;\r\n\r\n /**\r\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\r\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\r\n */\r\n enableSchemasPreload?: boolean;\r\n\r\n /**\r\n * Factory method for creating separate managers for each client\r\n * @internal\r\n */\r\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\r\n\r\n /**\r\n * How much time should an unused client manager be stored in memory\r\n * before it's disposed.\r\n */\r\n unusedClientLifetime?: number;\r\n}\r\n\r\n/**\r\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\r\n * instances, one for each frontend.\r\n *\r\n * @public\r\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\r\n */\r\nexport type MultiManagerPresentationProps = PresentationProps;\r\n\r\n/**\r\n * Base props for initializing the [[Presentation]] library.\r\n *\r\n * @public\r\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\r\n */\r\nexport type PresentationPropsBase = PresentationProps;\r\n\r\n/**\r\n * Props for initializing the [[Presentation]] library with ability to use a single\r\n * [[PresentationManager]] instance for handling all requests.\r\n *\r\n * @public\r\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\r\n */\r\nexport type SingleManagerPresentationProps = Omit<PresentationProps, \"clientManagerFactory\" | \"unusedClientLifetime\">;\r\n\r\ninterface ClientStoreItem {\r\n manager: PresentationManager;\r\n}\r\n\r\n/**\r\n * Static class used to statically set up Presentation library for the backend.\r\n * Basically what it does is:\r\n * - Register a RPC implementation\r\n * - Create a singleton [[PresentationManager]] instance\r\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\r\n * the presentation manager when that happens.\r\n *\r\n * @public\r\n */\r\nexport class Presentation {\r\n private static _initProps: PresentationProps | undefined;\r\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\r\n private static _disposeIpcHandler: DisposeFunc | undefined;\r\n private static _shutdownListener: DisposeFunc | undefined;\r\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\r\n private static _rpcImpl: PresentationRpcImpl | undefined;\r\n\r\n /* istanbul ignore next */\r\n private constructor() {}\r\n\r\n /** Properties used to initialize the presentation framework */\r\n public static get initProps() {\r\n return this._initProps;\r\n }\r\n\r\n /**\r\n * Initializes Presentation library for the backend.\r\n *\r\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\r\n *\r\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\r\n *\r\n * @param props Optional properties for [[PresentationManager]]\r\n */\r\n public static initialize(props?: PresentationProps): void {\r\n this._initProps = props || {};\r\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\r\n\r\n this._rpcImpl = new PresentationRpcImpl({\r\n requestTimeout: this._initProps.requestTimeout,\r\n });\r\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\r\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\r\n\r\n if (IpcHost.isValid) {\r\n this._disposeIpcHandler = PresentationIpcHandler.register();\r\n }\r\n\r\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\r\n factory: this.createClientManager.bind(this),\r\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\r\n // cleanup unused managers every minute\r\n cleanupInterval: 60 * 1000,\r\n // by default, manager is disposed after 1 hour of being unused\r\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\r\n // add some logging\r\n onDisposedSingle: /* istanbul ignore next */ (id: string) =>\r\n Logger.logInfo(\r\n PresentationBackendLoggerCategory.PresentationManager,\r\n `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`,\r\n ),\r\n onDisposedAll: /* istanbul ignore next */ () =>\r\n Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\r\n });\r\n\r\n if (this._initProps.enableSchemasPreload) {\r\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\r\n }\r\n }\r\n\r\n /**\r\n * Terminates Presentation. Consumers don't need to call this as it's automatically\r\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\r\n */\r\n public static terminate(): void {\r\n if (this._clientsStorage) {\r\n this._clientsStorage.dispose();\r\n this._clientsStorage = undefined;\r\n }\r\n if (this._disposeIModelOpenedListener) {\r\n this._disposeIModelOpenedListener();\r\n this._disposeIModelOpenedListener = undefined;\r\n }\r\n if (this._shutdownListener) {\r\n this._shutdownListener();\r\n this._shutdownListener = undefined;\r\n }\r\n RpcManager.unregisterImpl(PresentationRpcInterface);\r\n if (this._rpcImpl) {\r\n this._rpcImpl.dispose();\r\n this._rpcImpl = undefined;\r\n }\r\n if (this._disposeIpcHandler) {\r\n this._disposeIpcHandler();\r\n }\r\n this._initProps = undefined;\r\n }\r\n\r\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\r\n const manager =\r\n Presentation._initProps && Presentation._initProps.clientManagerFactory\r\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\r\n : new PresentationManager({ ...Presentation._initProps, id: clientId });\r\n manager.setOnManagerUsedHandler(onManagerUsed);\r\n Logger.logInfo(\r\n PresentationBackendLoggerCategory.PresentationManager,\r\n `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`,\r\n );\r\n return { manager };\r\n }\r\n\r\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\r\n storeItem.manager.dispose();\r\n }\r\n\r\n /**\r\n * Get an instance of [[PresentationManager]] for specific client\r\n * @param clientId ID of the client requesting presentation data. If no\r\n * ID is provided, the default [[PresentationManager]] is returned.\r\n */\r\n public static getManager(clientId?: string): PresentationManager {\r\n if (this._clientsStorage) {\r\n return this._clientsStorage.getValue(clientId || \"\").manager;\r\n }\r\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\r\n }\r\n\r\n /**\r\n * Get the time in milliseconds that backend should respond in .\r\n */\r\n public static getRequestTimeout(): number {\r\n if (this._rpcImpl === undefined) {\r\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\r\n }\r\n return this._rpcImpl.requestTimeout;\r\n }\r\n\r\n private static onIModelOpened = (imodel: BriefcaseDb) => {\r\n const manager = this.getManager();\r\n const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n manager.getNativePlatform().forceLoadSchemas(imodelAddon);\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAuE;AACvE,sDAA0D;AAC1D,oDAAgD;AAChD,oEAA6G;AAC7G,mEAA4E;AAC5E,qEAAkE;AAClE,+DAAsF;AACtF,+DAA4D;AAC5D,yDAAkE;AA6DlE;;;;;;;;;GASG;AACH,MAAa,YAAY;IACf,MAAM,CAAC,UAAU,CAAgC;IACjD,MAAM,CAAC,eAAe,CAA4D;IAClF,MAAM,CAAC,kBAAkB,CAA0B;IACnD,MAAM,CAAC,iBAAiB,CAA0B;IAClD,MAAM,CAAC,4BAA4B,CAA0B;IAC7D,MAAM,CAAC,QAAQ,CAAkC;IAEzD,0BAA0B;IAC1B,gBAAuB,CAAC;IAExB,+DAA+D;IACxD,MAAM,KAAK,SAAS;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,UAAU,CAAC,KAAyB;QAChD,IAAI,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,yBAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,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gB,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC,CAAC;;AArIJ,oCAsIC","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 { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\nimport { RpcManager } from \"@itwin/core-common\";\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler\";\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl\";\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage\";\n\n/**\n * Properties that can be used to configure [[Presentation]] API.\n * @public\n */\nexport interface PresentationProps extends Omit<PresentationManagerProps, \"enableSchemasPreload\"> {\n /**\n * Time in milliseconds after which the request will timeout.\n */\n requestTimeout?: number;\n\n /**\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n */\n enableSchemasPreload?: boolean;\n\n /**\n * Factory method for creating separate managers for each client\n * @internal\n */\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\n\n /**\n * How much time should an unused client manager be stored in memory\n * before it's disposed.\n */\n unusedClientLifetime?: number;\n}\n\n/**\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\n * instances, one for each frontend.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type MultiManagerPresentationProps = PresentationProps;\n\n/**\n * Base props for initializing the [[Presentation]] library.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type PresentationPropsBase = PresentationProps;\n\n/**\n * Props for initializing the [[Presentation]] library with ability to use a single\n * [[PresentationManager]] instance for handling all requests.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type SingleManagerPresentationProps = Omit<PresentationProps, \"clientManagerFactory\" | \"unusedClientLifetime\">;\n\ninterface ClientStoreItem {\n manager: PresentationManager;\n}\n\n/**\n * Static class used to statically set up Presentation library for the backend.\n * Basically what it does is:\n * - Register a RPC implementation\n * - Create a singleton [[PresentationManager]] instance\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\n * the presentation manager when that happens.\n *\n * @public\n */\nexport class Presentation {\n private static _initProps: PresentationProps | undefined;\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\n private static _disposeIpcHandler: DisposeFunc | undefined;\n private static _shutdownListener: DisposeFunc | undefined;\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\n private static _rpcImpl: PresentationRpcImpl | undefined;\n\n /* istanbul ignore next */\n private constructor() {}\n\n /** Properties used to initialize the presentation framework */\n public static get initProps() {\n return this._initProps;\n }\n\n /**\n * Initializes Presentation library for the backend.\n *\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\n *\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\n *\n * @param props Optional properties for [[PresentationManager]]\n */\n public static initialize(props?: PresentationProps): void {\n this._initProps = props || {};\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\n\n this._rpcImpl = new PresentationRpcImpl({\n requestTimeout: this._initProps.requestTimeout,\n });\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\n\n if (IpcHost.isValid) {\n this._disposeIpcHandler = PresentationIpcHandler.register();\n }\n\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\n factory: this.createClientManager.bind(this),\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\n // cleanup unused managers every minute\n cleanupInterval: 60 * 1000,\n // by default, manager is disposed after 1 hour of being unused\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\n // add some logging\n onDisposedSingle: /* istanbul ignore next */ (id: string) =>\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`,\n ),\n onDisposedAll: /* istanbul ignore next */ () =>\n Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\n });\n\n if (this._initProps.enableSchemasPreload) {\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\n }\n }\n\n /**\n * Terminates Presentation. Consumers don't need to call this as it's automatically\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\n */\n public static terminate(): void {\n if (this._clientsStorage) {\n this._clientsStorage[Symbol.dispose]();\n this._clientsStorage = undefined;\n }\n if (this._disposeIModelOpenedListener) {\n this._disposeIModelOpenedListener();\n this._disposeIModelOpenedListener = undefined;\n }\n if (this._shutdownListener) {\n this._shutdownListener();\n this._shutdownListener = undefined;\n }\n RpcManager.unregisterImpl(PresentationRpcInterface);\n if (this._rpcImpl) {\n this._rpcImpl[Symbol.dispose]();\n this._rpcImpl = undefined;\n }\n if (this._disposeIpcHandler) {\n this._disposeIpcHandler();\n }\n this._initProps = undefined;\n }\n\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\n const manager =\n Presentation._initProps && Presentation._initProps.clientManagerFactory\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\n : new PresentationManager({ ...Presentation._initProps, id: clientId });\n manager.setOnManagerUsedHandler(onManagerUsed);\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`,\n );\n return { manager };\n }\n\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\n storeItem.manager[Symbol.dispose]();\n }\n\n /**\n * Get an instance of [[PresentationManager]] for specific client\n * @param clientId ID of the client requesting presentation data. If no\n * ID is provided, the default [[PresentationManager]] is returned.\n */\n public static getManager(clientId?: string): PresentationManager {\n if (this._clientsStorage) {\n return this._clientsStorage.getValue(clientId || \"\").manager;\n }\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n\n /**\n * Get the time in milliseconds that backend should respond in .\n */\n public static getRequestTimeout(): number {\n if (this._rpcImpl === undefined) {\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n return this._rpcImpl.requestTimeout;\n }\n\n private static onIModelOpened = (imodel: BriefcaseDb) => {\n const manager = this.getManager();\n const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n manager.getNativePlatform().forceLoadSchemas(imodelAddon);\n };\n}\n"]}
|
|
@@ -13,10 +13,7 @@ const presentation_common_1 = require("@itwin/presentation-common");
|
|
|
13
13
|
const Presentation_1 = require("./Presentation");
|
|
14
14
|
/** @internal */
|
|
15
15
|
class PresentationIpcHandler extends core_backend_1.IpcHandler {
|
|
16
|
-
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.channelName = presentation_common_1.PRESENTATION_IPC_CHANNEL_NAME;
|
|
19
|
-
}
|
|
16
|
+
channelName = presentation_common_1.PRESENTATION_IPC_CHANNEL_NAME;
|
|
20
17
|
async setRulesetVariable(params) {
|
|
21
18
|
const { clientId, rulesetId, variable } = params;
|
|
22
19
|
const parsedVariable = presentation_common_1.RulesetVariable.fromJSON(variable);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationIpcHandler.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAiD;AACjD,oEAOoC;AACpC,iDAA8C;AAE9C,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,yBAAU;
|
|
1
|
+
{"version":3,"file":"PresentationIpcHandler.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAiD;AACjD,oEAOoC;AACpC,iDAA8C;AAE9C,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,yBAAU;IAC7C,WAAW,GAAG,mDAA6B,CAAC;IAE5C,KAAK,CAAC,kBAAkB,CAAC,MAAqD;QACnF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QACjD,MAAM,cAAc,GAAG,qCAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1D,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3H,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAClE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QACnD,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;CACF;AAbD,wDAaC","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 RPC\n */\n\nimport { IpcHandler } from \"@itwin/core-backend\";\nimport {\n PRESENTATION_IPC_CHANNEL_NAME,\n PresentationIpcInterface,\n RulesetVariable,\n RulesetVariableJSON,\n SetRulesetVariableParams,\n UnsetRulesetVariableParams,\n} from \"@itwin/presentation-common\";\nimport { Presentation } from \"./Presentation\";\n\n/** @internal */\nexport class PresentationIpcHandler extends IpcHandler implements PresentationIpcInterface {\n public channelName = PRESENTATION_IPC_CHANNEL_NAME;\n\n public async setRulesetVariable(params: SetRulesetVariableParams<RulesetVariableJSON>): Promise<void> {\n const { clientId, rulesetId, variable } = params;\n const parsedVariable = RulesetVariable.fromJSON(variable);\n Presentation.getManager(clientId).vars(rulesetId).setValue(parsedVariable.id, parsedVariable.type, parsedVariable.value);\n }\n\n public async unsetRulesetVariable(params: UnsetRulesetVariableParams): Promise<void> {\n const { clientId, rulesetId, variableId } = params;\n Presentation.getManager(clientId).vars(rulesetId).unset(variableId);\n }\n}\n"]}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
4
|
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
6
5
|
import { UnitSystemKey } from "@itwin/core-quantity";
|
|
7
6
|
import { SchemaContext } from "@itwin/ecschema-metadata";
|
|
8
7
|
import { UnitSystemFormat as CommonUnitSystemFormat, ComputeSelectionRequestOptions, Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, FormatsMap, HierarchyCompareInfo, HierarchyCompareOptions, HierarchyLevelDescriptorRequestOptions, HierarchyRequestOptions, InstanceKey, Item, KeySet, LabelDefinition, MultiElementPropertiesRequestOptions, Node, NodeKey, NodePathElement, Paged, PagedResponse, Prioritized, Ruleset, RulesetVariable, SelectClassInfo, SelectionScope, SelectionScopeRequestOptions, SingleElementPropertiesRequestOptions, WithCancelEvent } from "@itwin/presentation-common";
|
|
@@ -11,23 +10,6 @@ import { PresentationManagerDetail } from "./PresentationManagerDetail";
|
|
|
11
10
|
import { RulesetManager } from "./RulesetManager";
|
|
12
11
|
import { RulesetVariablesManager } from "./RulesetVariablesManager";
|
|
13
12
|
import { BackendDiagnosticsAttribute, BackendDiagnosticsOptions } from "./Utils";
|
|
14
|
-
/**
|
|
15
|
-
* Presentation manager working mode.
|
|
16
|
-
* @public
|
|
17
|
-
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
18
|
-
*/
|
|
19
|
-
export declare enum PresentationManagerMode {
|
|
20
|
-
/**
|
|
21
|
-
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
22
|
-
* related to reacting to changes in iModels.
|
|
23
|
-
*/
|
|
24
|
-
ReadOnly = 0,
|
|
25
|
-
/**
|
|
26
|
-
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
27
|
-
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
28
|
-
*/
|
|
29
|
-
ReadWrite = 1
|
|
30
|
-
}
|
|
31
13
|
/**
|
|
32
14
|
* Presentation hierarchy cache mode.
|
|
33
15
|
* @public
|
|
@@ -171,12 +153,6 @@ export interface PresentationAssetsRootConfig {
|
|
|
171
153
|
* Path to `presentation-backend` assets. Relative paths start from `process.cwd()`.
|
|
172
154
|
*/
|
|
173
155
|
backend: string;
|
|
174
|
-
/**
|
|
175
|
-
* Path to `presentation-common` assets.
|
|
176
|
-
*
|
|
177
|
-
* @deprecated in 3.x. This path is not used anymore
|
|
178
|
-
*/
|
|
179
|
-
common: string;
|
|
180
156
|
}
|
|
181
157
|
/**
|
|
182
158
|
* Properties that can be used to configure [[PresentationManager]]
|
|
@@ -217,20 +193,6 @@ export interface PresentationManagerProps {
|
|
|
217
193
|
* @note Only files with `.PresentationRuleSet.json` are read.
|
|
218
194
|
*/
|
|
219
195
|
supplementalRulesetDirectories?: string[];
|
|
220
|
-
/**
|
|
221
|
-
* A list of directories containing application's locale-specific localized
|
|
222
|
-
* string files (in simplified i18next v3 format)
|
|
223
|
-
*
|
|
224
|
-
* @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
225
|
-
*/
|
|
226
|
-
localeDirectories?: string[];
|
|
227
|
-
/**
|
|
228
|
-
* Sets the active locale to use when localizing presentation-related
|
|
229
|
-
* strings. It can later be changed through [[PresentationManager.activeLocale]].
|
|
230
|
-
*
|
|
231
|
-
* @deprecated in 3.x. Use [[getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
232
|
-
*/
|
|
233
|
-
defaultLocale?: string;
|
|
234
196
|
/**
|
|
235
197
|
* Sets the active unit system to use for formatting property values with
|
|
236
198
|
* units. Default presentation units are used if this is not specified. The active unit
|
|
@@ -243,26 +205,10 @@ export interface PresentationManagerProps {
|
|
|
243
205
|
* in requested unit system.
|
|
244
206
|
*/
|
|
245
207
|
defaultFormats?: FormatsMap;
|
|
246
|
-
/**
|
|
247
|
-
* Should schemas preloading be enabled. If true, presentation manager listens
|
|
248
|
-
* for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.
|
|
249
|
-
*
|
|
250
|
-
* @deprecated in 3.x. Use [[PresentationProps.enableSchemasPreload]] instead.
|
|
251
|
-
*/
|
|
252
|
-
enableSchemasPreload?: boolean;
|
|
253
208
|
/**
|
|
254
209
|
* A number of worker threads to use for handling presentation requests. Defaults to `2`.
|
|
255
210
|
*/
|
|
256
211
|
workerThreadsCount?: number;
|
|
257
|
-
/**
|
|
258
|
-
* Presentation manager working mode. Backends that use iModels in read-write mode should
|
|
259
|
-
* use `ReadWrite`, others might want to set to `ReadOnly` for better performance.
|
|
260
|
-
*
|
|
261
|
-
* Defaults to [[PresentationManagerMode.ReadWrite]].
|
|
262
|
-
*
|
|
263
|
-
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
264
|
-
*/
|
|
265
|
-
mode?: PresentationManagerMode;
|
|
266
212
|
/**
|
|
267
213
|
* The interval (in milliseconds) used to poll for presentation data changes. If not set, presentation
|
|
268
214
|
* data changes are not tracked at all.
|
|
@@ -321,11 +267,6 @@ export declare class PresentationManager {
|
|
|
321
267
|
private _props;
|
|
322
268
|
private _detail;
|
|
323
269
|
private _localizationHelper;
|
|
324
|
-
/**
|
|
325
|
-
* Get / set active locale used for localizing presentation data
|
|
326
|
-
* @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
327
|
-
*/
|
|
328
|
-
activeLocale: string | undefined;
|
|
329
270
|
/**
|
|
330
271
|
* Creates an instance of PresentationManager.
|
|
331
272
|
* @param props Optional configuration properties.
|
|
@@ -335,6 +276,8 @@ export declare class PresentationManager {
|
|
|
335
276
|
get activeUnitSystem(): UnitSystemKey | undefined;
|
|
336
277
|
set activeUnitSystem(value: UnitSystemKey | undefined);
|
|
337
278
|
/** Dispose the presentation manager. Must be called to clean up native resources. */
|
|
279
|
+
[Symbol.dispose](): void;
|
|
280
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
338
281
|
dispose(): void;
|
|
339
282
|
/** @internal */
|
|
340
283
|
setOnManagerUsedHandler(handler: () => void): void;
|
|
@@ -439,20 +382,13 @@ export declare class PresentationManager {
|
|
|
439
382
|
/**
|
|
440
383
|
* Retrieves available selection scopes.
|
|
441
384
|
* @public
|
|
385
|
+
* @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.
|
|
442
386
|
*/
|
|
443
387
|
getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<SelectionScope[]>;
|
|
444
|
-
/**
|
|
445
|
-
* Computes selection set based on provided selection scope.
|
|
446
|
-
* @public
|
|
447
|
-
* @deprecated in 3.x. Use overload with `ComputeSelectionRequestOptions` parameter.
|
|
448
|
-
*/
|
|
449
|
-
computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb> & {
|
|
450
|
-
ids: Id64String[];
|
|
451
|
-
scopeId: string;
|
|
452
|
-
} & BackendDiagnosticsAttribute): Promise<KeySet>;
|
|
453
388
|
/**
|
|
454
389
|
* Computes selection based on provided element IDs and selection scope.
|
|
455
390
|
* @public
|
|
391
|
+
* @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.
|
|
456
392
|
*/
|
|
457
393
|
computeSelection(requestOptions: ComputeSelectionRequestOptions<IModelDb> & BackendDiagnosticsAttribute): Promise<KeySet>;
|
|
458
394
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAEL,gBAAgB,IAAI,sBAAsB,EAC1C,8BAA8B,EAC9B,OAAO,EACP,+BAA+B,EAI/B,qBAAqB,EACrB,4BAA4B,EAG5B,UAAU,EACV,mBAAmB,EACnB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EACjB,4BAA4B,EAC5B,iBAAiB,EACjB,4CAA4C,EAC5C,mCAAmC,EACnC,UAAU,EACV,oBAAoB,EACpB,uBAAuB,EAEvB,sCAAsC,EACtC,uBAAuB,EACvB,WAAW,EAEX,IAAI,EACJ,MAAM,EAEN,eAAe,EAEf,oCAAoC,E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4B;IA6E1C;;;OAGG;IACU,yBAAyB,CACpC,cAAc,EAAE,eAAe,CAAC,WAAW,CAAC,0BAA0B,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,2BAA2B,GAC5H,OAAO,CAAC,eAAe,CAAC;IAK3B;;;OAGG;IACU,0BAA0B,CACrC,cAAc,EAAE,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,2BAA2B,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,2BAA2B,GACpI,OAAO,CAAC,eAAe,EAAE,CAAC;IAK7B;;;;OAIG;IAEU,kBAAkB,CAAC,eAAe,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAAG,2BAA2B,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIjJ;;;;OAIG;IAEU,gBAAgB,CAAC,cAAc,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAAG,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAItI;;;OAGG;IACU,kBAAkB,CAAC,cAAc,EAAE,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA4B3H"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.PresentationManager = exports.HierarchyCacheMode =
|
|
10
|
+
exports.PresentationManager = exports.HierarchyCacheMode = void 0;
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const rxjs_for_await_1 = require("rxjs-for-await");
|
|
13
13
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
@@ -17,24 +17,6 @@ const PresentationManagerDetail_1 = require("./PresentationManagerDetail");
|
|
|
17
17
|
const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
|
|
18
18
|
const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
|
|
19
19
|
const Utils_1 = require("./Utils");
|
|
20
|
-
/**
|
|
21
|
-
* Presentation manager working mode.
|
|
22
|
-
* @public
|
|
23
|
-
* @deprecated in 3.x. The attribute is not used by [[PresentationManager]] anymore
|
|
24
|
-
*/
|
|
25
|
-
var PresentationManagerMode;
|
|
26
|
-
(function (PresentationManagerMode) {
|
|
27
|
-
/**
|
|
28
|
-
* Presentation manager assumes iModels are opened in read-only mode and avoids doing some work
|
|
29
|
-
* related to reacting to changes in iModels.
|
|
30
|
-
*/
|
|
31
|
-
PresentationManagerMode[PresentationManagerMode["ReadOnly"] = 0] = "ReadOnly";
|
|
32
|
-
/**
|
|
33
|
-
* Presentation manager assumes iModels are opened in read-write mode and it may need to
|
|
34
|
-
* react to changes. This involves some additional work and gives slightly worse performance.
|
|
35
|
-
*/
|
|
36
|
-
PresentationManagerMode[PresentationManagerMode["ReadWrite"] = 1] = "ReadWrite";
|
|
37
|
-
})(PresentationManagerMode || (exports.PresentationManagerMode = PresentationManagerMode = {}));
|
|
38
20
|
/**
|
|
39
21
|
* Presentation hierarchy cache mode.
|
|
40
22
|
* @public
|
|
@@ -65,18 +47,16 @@ var HierarchyCacheMode;
|
|
|
65
47
|
* @public
|
|
66
48
|
*/
|
|
67
49
|
class PresentationManager {
|
|
50
|
+
_props;
|
|
51
|
+
_detail;
|
|
52
|
+
_localizationHelper;
|
|
68
53
|
/**
|
|
69
54
|
* Creates an instance of PresentationManager.
|
|
70
55
|
* @param props Optional configuration properties.
|
|
71
56
|
*/
|
|
72
57
|
constructor(props) {
|
|
73
|
-
/** @internal */
|
|
74
|
-
this.getNativePlatform = () => {
|
|
75
|
-
return this._detail.getNativePlatform();
|
|
76
|
-
};
|
|
77
58
|
this._props = props ?? {};
|
|
78
59
|
this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
|
|
79
|
-
this.activeLocale = this._props.defaultLocale; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
80
60
|
this._localizationHelper = new presentation_common_1.LocalizationHelper({ getLocalizedString: props?.getLocalizedString ?? Utils_1.getLocalizedStringEN });
|
|
81
61
|
}
|
|
82
62
|
/** Get / set active unit system used to format property values with units */
|
|
@@ -88,8 +68,13 @@ class PresentationManager {
|
|
|
88
68
|
this._detail.activeUnitSystem = value;
|
|
89
69
|
}
|
|
90
70
|
/** Dispose the presentation manager. Must be called to clean up native resources. */
|
|
71
|
+
[Symbol.dispose]() {
|
|
72
|
+
this._detail[Symbol.dispose]();
|
|
73
|
+
}
|
|
74
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
75
|
+
// istanbul ignore next
|
|
91
76
|
dispose() {
|
|
92
|
-
this.
|
|
77
|
+
this[Symbol.dispose]();
|
|
93
78
|
}
|
|
94
79
|
/** @internal */
|
|
95
80
|
setOnManagerUsedHandler(handler) {
|
|
@@ -111,6 +96,10 @@ class PresentationManager {
|
|
|
111
96
|
return new RulesetVariablesManager_1.RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);
|
|
112
97
|
}
|
|
113
98
|
/** @internal */
|
|
99
|
+
getNativePlatform = () => {
|
|
100
|
+
return this._detail.getNativePlatform();
|
|
101
|
+
};
|
|
102
|
+
/** @internal */
|
|
114
103
|
// istanbul ignore next
|
|
115
104
|
getDetail() {
|
|
116
105
|
return this._detail;
|
|
@@ -124,11 +113,9 @@ class PresentationManager {
|
|
|
124
113
|
* @public
|
|
125
114
|
*/
|
|
126
115
|
async getNodes(requestOptions) {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const nodes = presentation_common_1.Node.listFromJSON(nodesJson.nodes);
|
|
131
|
-
return this._localizationHelper.getLocalizedNodes(nodes);
|
|
116
|
+
const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);
|
|
117
|
+
const hierarchyLevel = (0, presentation_common_1.deepReplaceNullsToUndefined)(JSON.parse(serializedHierarchyLevel));
|
|
118
|
+
return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);
|
|
132
119
|
}
|
|
133
120
|
/**
|
|
134
121
|
* Retrieves nodes count
|
|
@@ -260,7 +247,7 @@ class PresentationManager {
|
|
|
260
247
|
return parser(content.descriptor, content.contentSet[0]);
|
|
261
248
|
}
|
|
262
249
|
async getMultipleElementProperties(requestOptions) {
|
|
263
|
-
const {
|
|
250
|
+
const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;
|
|
264
251
|
const parser = contentParser ?? presentation_common_1.buildElementProperties;
|
|
265
252
|
const workerThreadsCount = this._props.workerThreadsCount ?? 2;
|
|
266
253
|
// We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory
|
|
@@ -268,75 +255,40 @@ class PresentationManager {
|
|
|
268
255
|
// but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at
|
|
269
256
|
// most `workerThreadsCount / 2` classes in parallel.
|
|
270
257
|
// istanbul ignore next
|
|
271
|
-
const classParallelism = workerThreadsCount > 1 ? workerThreadsCount / 2 : 1;
|
|
258
|
+
const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;
|
|
272
259
|
// We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,
|
|
273
260
|
// but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.
|
|
274
261
|
// To avoid that, we keep twice as much requests active.
|
|
275
262
|
// istanbul ignore next
|
|
276
|
-
const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const getContentDescriptor = async (ruleset) => {
|
|
300
|
-
return (await this.getContentDescriptor({
|
|
301
|
-
...contentOptions,
|
|
302
|
-
rulesetOrId: ruleset,
|
|
303
|
-
displayType: presentation_common_1.DefaultContentDisplayTypes.Grid,
|
|
304
|
-
contentFlags: presentation_common_1.ContentFlags.ShowLabels,
|
|
305
|
-
keys: new presentation_common_1.KeySet(),
|
|
306
|
-
}));
|
|
307
|
-
};
|
|
308
|
-
const obs = (0, ElementPropertiesHelper_1.getClassesWithInstances)(requestOptions.imodel, elementClasses ?? /* istanbul ignore next */ ["BisCore.Element"]).pipe((0, rxjs_1.map)((classFullName) => ({
|
|
309
|
-
classFullName,
|
|
310
|
-
ruleset: createClassContentRuleset(classFullName),
|
|
311
|
-
})), (0, rxjs_1.mergeMap)(({ classFullName, ruleset }) =>
|
|
312
|
-
// use forkJoin to query descriptor and element ids in parallel
|
|
313
|
-
(0, rxjs_1.forkJoin)({
|
|
314
|
-
classFullName: (0, rxjs_1.of)(classFullName),
|
|
315
|
-
ruleset: (0, rxjs_1.of)(ruleset),
|
|
316
|
-
descriptor: (0, rxjs_1.from)(getContentDescriptor(ruleset)),
|
|
317
|
-
batches: (0, rxjs_1.from)((0, ElementPropertiesHelper_1.getBatchedClassElementIds)(requestOptions.imodel, classFullName, batchSize ?? /* istanbul ignore next */ 1000)),
|
|
318
|
-
}).pipe(
|
|
319
|
-
// split incoming stream into individual batch requests
|
|
320
|
-
(0, rxjs_1.mergeMap)(({ descriptor, batches }) => (0, rxjs_1.from)(batches.map((batch) => ({ classFullName, descriptor, batch })))),
|
|
321
|
-
// request content for each batch, filter by IDs for performance
|
|
322
|
-
(0, rxjs_1.mergeMap)(({ descriptor, batch }) => {
|
|
323
|
-
const filteringDescriptor = new presentation_common_1.Descriptor(descriptor);
|
|
324
|
-
filteringDescriptor.instanceFilter = {
|
|
325
|
-
selectClassName: classFullName,
|
|
326
|
-
expression: `this.ECInstanceId >= ${Number.parseInt(batch.from, 16)} AND this.ECInstanceId <= ${Number.parseInt(batch.to, 16)}`,
|
|
327
|
-
};
|
|
328
|
-
return (0, rxjs_1.from)(this.getContentSet({
|
|
329
|
-
...contentOptions,
|
|
330
|
-
keys: new presentation_common_1.KeySet(),
|
|
331
|
-
descriptor: filteringDescriptor,
|
|
332
|
-
rulesetOrId: ruleset,
|
|
333
|
-
})).pipe((0, rxjs_1.map)((items) => ({ classFullName, descriptor, items })));
|
|
334
|
-
}, batchesParallelism)), classParallelism), (0, rxjs_1.map)(({ descriptor, items }) => items.map((item) => parser(descriptor, item))));
|
|
263
|
+
const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;
|
|
264
|
+
// istanbul ignore next
|
|
265
|
+
const batchSize = batchSizeOption ?? 100;
|
|
266
|
+
const elementsIdentifier = (() => {
|
|
267
|
+
if ("elementIds" in contentOptions && contentOptions.elementIds !== undefined) {
|
|
268
|
+
const elementIds = contentOptions.elementIds;
|
|
269
|
+
delete contentOptions.elementIds;
|
|
270
|
+
return { elementIds };
|
|
271
|
+
}
|
|
272
|
+
// istanbul ignore else
|
|
273
|
+
if ("elementClasses" in contentOptions && contentOptions.elementClasses !== undefined) {
|
|
274
|
+
const elementClasses = contentOptions.elementClasses;
|
|
275
|
+
delete contentOptions.elementClasses;
|
|
276
|
+
return { elementClasses };
|
|
277
|
+
}
|
|
278
|
+
// istanbul ignore next
|
|
279
|
+
return { elementClasses: ["BisCore:Element"] };
|
|
280
|
+
})();
|
|
281
|
+
const descriptorGetter = async (partialProps) => this.getContentDescriptor({ ...contentOptions, displayType: presentation_common_1.DefaultContentDisplayTypes.Grid, contentFlags: presentation_common_1.ContentFlags.ShowLabels, ...partialProps });
|
|
282
|
+
const contentSetGetter = async (partialProps) => this.getContentSet({ ...contentOptions, ...partialProps });
|
|
283
|
+
const { itemBatches, count } = "elementIds" in elementsIdentifier
|
|
284
|
+
? (0, ElementPropertiesHelper_1.getContentItemsObservableFromElementIds)(requestOptions.imodel, descriptorGetter, contentSetGetter, elementsIdentifier.elementIds, classParallelism, batchesParallelism, batchSize)
|
|
285
|
+
: (0, ElementPropertiesHelper_1.getContentItemsObservableFromClassNames)(requestOptions.imodel, descriptorGetter, contentSetGetter, elementsIdentifier.elementClasses, classParallelism, batchesParallelism, batchSize);
|
|
335
286
|
return {
|
|
336
|
-
total: (0,
|
|
287
|
+
total: await (0, rxjs_1.firstValueFrom)(count),
|
|
337
288
|
async *iterator() {
|
|
338
|
-
for await (const
|
|
339
|
-
|
|
289
|
+
for await (const itemsBatch of (0, rxjs_for_await_1.eachValueFrom)(itemBatches)) {
|
|
290
|
+
const { descriptor, items } = itemsBatch;
|
|
291
|
+
yield items.map((item) => parser(descriptor, item));
|
|
340
292
|
}
|
|
341
293
|
},
|
|
342
294
|
};
|
|
@@ -360,17 +312,20 @@ class PresentationManager {
|
|
|
360
312
|
/**
|
|
361
313
|
* Retrieves available selection scopes.
|
|
362
314
|
* @public
|
|
315
|
+
* @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.
|
|
363
316
|
*/
|
|
317
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
364
318
|
async getSelectionScopes(_requestOptions) {
|
|
365
319
|
return SelectionScopesHelper_1.SelectionScopesHelper.getSelectionScopes();
|
|
366
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Computes selection based on provided element IDs and selection scope.
|
|
323
|
+
* @public
|
|
324
|
+
* @deprecated in 5.0. Use `computeSelection` from [@itwin/unified-selection](https://github.com/iTwin/presentation/blob/master/packages/unified-selection/README.md#selection-scopes) package instead.
|
|
325
|
+
*/
|
|
326
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
367
327
|
async computeSelection(requestOptions) {
|
|
368
|
-
return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection(
|
|
369
|
-
? requestOptions
|
|
370
|
-
: (function () {
|
|
371
|
-
const { ids, scopeId, ...rest } = requestOptions;
|
|
372
|
-
return { ...rest, elementIds: ids, scope: { id: scopeId } };
|
|
373
|
-
})());
|
|
328
|
+
return SelectionScopesHelper_1.SelectionScopesHelper.computeSelection(requestOptions);
|
|
374
329
|
}
|
|
375
330
|
/**
|
|
376
331
|
* Compares two hierarchies specified in the request options
|
|
@@ -398,9 +353,7 @@ class PresentationManager {
|
|
|
398
353
|
currRulesetVariables: JSON.stringify(currRulesetVariables),
|
|
399
354
|
expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),
|
|
400
355
|
};
|
|
401
|
-
|
|
402
|
-
const reviver = (key, value) => (key === "" ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value);
|
|
403
|
-
return JSON.parse(await this._detail.request(params), reviver);
|
|
356
|
+
return JSON.parse(await this._detail.request(params));
|
|
404
357
|
}
|
|
405
358
|
}
|
|
406
359
|
exports.PresentationManager = PresentationManager;
|