@itwin/presentation-backend 3.0.0-dev.72 → 3.0.0-dev.73
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/presentation-backend/Presentation.d.ts +1 -0
- package/lib/presentation-backend/Presentation.d.ts.map +1 -1
- package/lib/presentation-backend/Presentation.js +9 -8
- package/lib/presentation-backend/Presentation.js.map +1 -1
- package/lib/presentation-backend/PresentationManager.d.ts +1 -3
- package/lib/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/presentation-backend/PresentationManager.js +5 -12
- package/lib/presentation-backend/PresentationManager.js.map +1 -1
- package/package.json +19 -19
|
@@ -61,6 +61,7 @@ export declare class Presentation {
|
|
|
61
61
|
private static _initProps;
|
|
62
62
|
private static _clientsStorage;
|
|
63
63
|
private static _requestTimeout;
|
|
64
|
+
private static _disposeIpcHandler;
|
|
64
65
|
private static _shutdownListener;
|
|
65
66
|
private static _manager;
|
|
66
67
|
private constructor();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presentation.d.ts","sourceRoot":"","sources":["../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Presentation.d.ts","sourceRoot":"","sources":["../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":"AAIA;;GAEG;AAQH,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAMtF;;;;;GAKG;AACH,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB;IAC7E;;;OAGG;IACH,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,wBAAwB,KAAK,mBAAmB,CAAC;IAElG;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,WAAW,8BAA+B,SAAQ,wBAAwB;IAC9E;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;;GAGG;AACH,oBAAY,iBAAiB,GAAG,6BAA6B,GAAG,8BAA8B,CAAC;AAM/F;;;;;;;;;GASG;AACH,qBAAa,YAAY;IAEvB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAgC;IACzD,OAAO,CAAC,MAAM,CAAC,eAAe,CAAgD;IAC9E,OAAO,CAAC,MAAM,CAAC,eAAe,CAAqB;IACnD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAA0B;IAC3D,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA0B;IAC1D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkC;IAGzD,OAAO;IAEP,+DAA+D;IAC/D,WAAkB,SAAS,kCAA8B;IAEzD;;;;;;;;OAQG;WACW,UAAU,CAAC,KAAK,CAAC,EAAE,iBAAiB,GAAG,IAAI;IA6BzD;;;OAGG;WACW,SAAS,IAAI,IAAI;IAsB/B,OAAO,CAAC,MAAM,CAAC,mBAAmB;IASlC,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC;;;;OAIG;WACW,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,mBAAmB;IAShE;;OAEG;WACW,iBAAiB,IAAI,MAAM;CAK1C"}
|
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.Presentation = void 0;
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
11
|
const core_backend_1 = require("@itwin/core-backend");
|
|
12
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
13
|
const core_common_1 = require("@itwin/core-common");
|
|
14
14
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
15
15
|
const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
|
|
16
|
+
const PresentationIpcHandler_1 = require("./PresentationIpcHandler");
|
|
16
17
|
const PresentationManager_1 = require("./PresentationManager");
|
|
17
18
|
const PresentationRpcImpl_1 = require("./PresentationRpcImpl");
|
|
18
19
|
const TemporaryStorage_1 = require("./TemporaryStorage");
|
|
@@ -43,13 +44,9 @@ class Presentation {
|
|
|
43
44
|
*/
|
|
44
45
|
static initialize(props) {
|
|
45
46
|
var _a;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
catch (_e) {
|
|
50
|
-
// note: RpcManager.registerImpl throws when called more than once with the same
|
|
51
|
-
// rpc interface. However, it doesn't provide any way to unregister a, interface so we end up
|
|
52
|
-
// using the one registered first. At least we can avoid an exception...
|
|
47
|
+
core_common_1.RpcManager.registerImpl(presentation_common_1.PresentationRpcInterface, PresentationRpcImpl_1.PresentationRpcImpl);
|
|
48
|
+
if (core_backend_1.IpcHost.isValid) {
|
|
49
|
+
this._disposeIpcHandler = PresentationIpcHandler_1.PresentationIpcHandler.register();
|
|
53
50
|
}
|
|
54
51
|
this._initProps = props || {};
|
|
55
52
|
this._shutdownListener = core_backend_1.IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());
|
|
@@ -91,6 +88,10 @@ class Presentation {
|
|
|
91
88
|
this._manager.dispose();
|
|
92
89
|
this._manager = undefined;
|
|
93
90
|
}
|
|
91
|
+
core_common_1.RpcManager.unregisterImpl(presentation_common_1.PresentationRpcInterface);
|
|
92
|
+
if (this._disposeIpcHandler) {
|
|
93
|
+
this._disposeIpcHandler();
|
|
94
|
+
}
|
|
94
95
|
this._initProps = undefined;
|
|
95
96
|
if (this._requestTimeout)
|
|
96
97
|
this._requestTimeout = undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0D;AAC1D,sDAAiD;A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tE,CAAC","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 { DisposeFunc, Logger } from \"@itwin/core-bentley\";\nimport { IModelHost } from \"@itwin/core-backend\";\nimport { RpcManager } from \"@itwin/core-common\";\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl\";\nimport { TemporaryStorage } from \"./TemporaryStorage\";\n\nconst defaultRequestTimeout: number = 90000;\n\n/**\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\n * instances, one for each frontend.\n *\n * @public\n */\nexport interface MultiManagerPresentationProps extends PresentationManagerProps {\n /**\n * Factory method for creating separate managers for each client\n * @internal\n */\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\n\n /**\n * Time in milliseconds after which the request will timeout.\n */\n requestTimeout?: number;\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 with ability to use a single\n * [[PresentationManager]] instance for handling all requests.\n *\n * @public\n */\nexport interface SingleManagerPresentationProps extends PresentationManagerProps {\n /**\n * How much time should an unused client manager be stored in memory\n * before it's disposed.\n */\n requestTimeout?: number;\n\n /**\n * Specifies to use single manager for all clients.\n * @alpha\n */\n useSingleManager?: boolean;\n}\n\n/**\n * Properties that can be used to configure [[Presentation]] API\n * @public\n */\nexport type PresentationProps = MultiManagerPresentationProps | SingleManagerPresentationProps;\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\n private static _initProps: PresentationProps | undefined;\n private static _clientsStorage: TemporaryStorage<ClientStoreItem> | undefined;\n private static _requestTimeout: number | undefined;\n private static _shutdownListener: DisposeFunc | undefined;\n private static _manager: PresentationManager | undefined;\n\n /* istanbul ignore next */\n private constructor() { }\n\n /** Properties used to initialize the presentation framework */\n public static get initProps() { return this._initProps; }\n\n /**\n * Initializes Presentation library for the backend.\n *\n * See [this]($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 try {\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\n } catch (_e) {\n // note: RpcManager.registerImpl throws when called more than once with the same\n // rpc interface. However, it doesn't provide any way to unregister a, interface so we end up\n // using the one registered first. At least we can avoid an exception...\n }\n this._initProps = props || {};\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\n this._requestTimeout = (props && props.requestTimeout !== undefined)\n ? props.requestTimeout\n : defaultRequestTimeout;\n\n if (isSingleManagerProps(this._initProps)) {\n this._manager = new PresentationManager(Presentation._initProps);\n } else {\n this._clientsStorage = new TemporaryStorage<ClientStoreItem>({\n factory: this.createClientManager,\n cleanupHandler: this.disposeClientManager,\n // cleanup unused managers every minute\n cleanupInterval: 60 * 1000,\n // by default, manager is disposed after 1 hour of being unused\n valueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\n // add some logging\n onCreated: /* istanbul ignore next */ (id: string) => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage?.values.length}.`),\n onDisposedSingle: /* istanbul ignore next */ (id: string) => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage?.values.length}.`),\n onDisposedAll: /* istanbul ignore next */ () => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\n });\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.dispose();\n this._clientsStorage = undefined;\n }\n if (this._shutdownListener) {\n this._shutdownListener();\n this._shutdownListener = undefined;\n }\n if (this._manager) {\n this._manager.dispose();\n this._manager = undefined;\n }\n this._initProps = undefined;\n if (this._requestTimeout)\n this._requestTimeout = undefined;\n }\n\n private static createClientManager(clientId: string): ClientStoreItem {\n let manager: PresentationManager;\n if (Presentation._initProps && !isSingleManagerProps(Presentation._initProps) && Presentation._initProps.clientManagerFactory)\n manager = Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps);\n else\n manager = new PresentationManager(Presentation._initProps);\n return { manager };\n }\n\n private static disposeClientManager(storeItem: ClientStoreItem) {\n storeItem.manager.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._initProps && isSingleManagerProps(this._initProps) && this._manager)\n return this._manager;\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._requestTimeout === undefined)\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n return this._requestTimeout;\n }\n}\n\nfunction isSingleManagerProps(props: PresentationProps): props is SingleManagerPresentationProps {\n return !!(props as SingleManagerPresentationProps).useSingleManager;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA0D;AAC1D,sDAA0D;AAC1D,oDAAgD;AAChD,oEAA6G;AAC7G,mEAA4E;AAC5E,qEAAkE;AAClE,+DAAsF;AACtF,+DAA4D;AAC5D,yDAAsD;AAEtD,MAAM,qBAAqB,GAAW,KAAK,CAAC;AAyD5C;;;;;;;;;GASG;AACH,MAAa,YAAY;IASvB,0BAA0B;IAC1B,gBAAwB,CAAC;IAEzB,+DAA+D;IACxD,MAAM,KAAK,SAAS,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAEzD;;;;;;;;OAQG;IACI,MAAM,CAAC,UAAU,CAAC,KAAyB;;QAChD,wBAAU,CAAC,YAAY,CAAC,8CAAwB,EAAE,yCAAmB,CAAC,CAAC;QACvE,IAAI,sBAAO,CAAC,OAAO,EAAE;YACnB,IAAI,CAAC,kBAAkB,GAAG,+CAAsB,CAAC,QAAQ,EAAE,CAAC;SAC7D;QACD,IAAI,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,yBAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;QACjG,IAAI,CAAC,eAAe,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,cAAc,KAAK,SAAS,CAAC;YAClE,CAAC,CAAC,KAAK,CAAC,cAAc;YACtB,CAAC,CAAC,qBAAqB,CAAC;QAE1B,IAAI,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;YACzC,IAAI,CAAC,QAAQ,GAAG,IAAI,yCAAmB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;SAClE;aAAM;YACL,IAAI,CAAC,eAAe,GAAG,IA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CAAC,CAAC;IAC9I,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,iBAAiB;QAC7B,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS;YACpC,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,cAAc,EAAE,2EAA2E,CAAC,CAAC;QAC9I,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CACF;AAlHD,oCAkHC;AAED,SAAS,oBAAoB,CAAC,KAAwB;IACpD,OAAO,CAAC,CAAE,KAAwC,CAAC,gBAAgB,CAAC;AACtE,CAAC","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 { 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 { TemporaryStorage } from \"./TemporaryStorage\";\n\nconst defaultRequestTimeout: number = 90000;\n\n/**\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\n * instances, one for each frontend.\n *\n * @public\n */\nexport interface MultiManagerPresentationProps extends PresentationManagerProps {\n /**\n * Factory method for creating separate managers for each client\n * @internal\n */\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\n\n /**\n * Time in milliseconds after which the request will timeout.\n */\n requestTimeout?: number;\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 with ability to use a single\n * [[PresentationManager]] instance for handling all requests.\n *\n * @public\n */\nexport interface SingleManagerPresentationProps extends PresentationManagerProps {\n /**\n * How much time should an unused client manager be stored in memory\n * before it's disposed.\n */\n requestTimeout?: number;\n\n /**\n * Specifies to use single manager for all clients.\n * @alpha\n */\n useSingleManager?: boolean;\n}\n\n/**\n * Properties that can be used to configure [[Presentation]] API\n * @public\n */\nexport type PresentationProps = MultiManagerPresentationProps | SingleManagerPresentationProps;\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\n private static _initProps: PresentationProps | undefined;\n private static _clientsStorage: TemporaryStorage<ClientStoreItem> | undefined;\n private static _requestTimeout: number | undefined;\n private static _disposeIpcHandler: DisposeFunc | undefined;\n private static _shutdownListener: DisposeFunc | undefined;\n private static _manager: PresentationManager | undefined;\n\n /* istanbul ignore next */\n private constructor() { }\n\n /** Properties used to initialize the presentation framework */\n public static get initProps() { return this._initProps; }\n\n /**\n * Initializes Presentation library for the backend.\n *\n * See [this]($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 RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\n if (IpcHost.isValid) {\n this._disposeIpcHandler = PresentationIpcHandler.register();\n }\n this._initProps = props || {};\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\n this._requestTimeout = (props && props.requestTimeout !== undefined)\n ? props.requestTimeout\n : defaultRequestTimeout;\n\n if (isSingleManagerProps(this._initProps)) {\n this._manager = new PresentationManager(Presentation._initProps);\n } else {\n this._clientsStorage = new TemporaryStorage<ClientStoreItem>({\n factory: this.createClientManager,\n cleanupHandler: this.disposeClientManager,\n // cleanup unused managers every minute\n cleanupInterval: 60 * 1000,\n // by default, manager is disposed after 1 hour of being unused\n valueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\n // add some logging\n onCreated: /* istanbul ignore next */ (id: string) => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage?.values.length}.`),\n onDisposedSingle: /* istanbul ignore next */ (id: string) => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage?.values.length}.`),\n onDisposedAll: /* istanbul ignore next */ () => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\n });\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.dispose();\n this._clientsStorage = undefined;\n }\n if (this._shutdownListener) {\n this._shutdownListener();\n this._shutdownListener = undefined;\n }\n if (this._manager) {\n this._manager.dispose();\n this._manager = undefined;\n }\n RpcManager.unregisterImpl(PresentationRpcInterface);\n if (this._disposeIpcHandler) {\n this._disposeIpcHandler();\n }\n this._initProps = undefined;\n if (this._requestTimeout)\n this._requestTimeout = undefined;\n }\n\n private static createClientManager(clientId: string): ClientStoreItem {\n let manager: PresentationManager;\n if (Presentation._initProps && !isSingleManagerProps(Presentation._initProps) && Presentation._initProps.clientManagerFactory)\n manager = Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps);\n else\n manager = new PresentationManager(Presentation._initProps);\n return { manager };\n }\n\n private static disposeClientManager(storeItem: ClientStoreItem) {\n storeItem.manager.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._initProps && isSingleManagerProps(this._initProps) && this._manager)\n return this._manager;\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._requestTimeout === undefined)\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n return this._requestTimeout;\n }\n}\n\nfunction isSingleManagerProps(props: PresentationProps): props is SingleManagerPresentationProps {\n return !!(props as SingleManagerPresentationProps).useSingleManager;\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Core
|
|
3
3
|
*/
|
|
4
|
-
import { Id64String } from "@itwin/core-bentley";
|
|
5
4
|
import { IModelDb } from "@itwin/core-backend";
|
|
5
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
6
6
|
import { FormatProps, UnitSystemKey } from "@itwin/core-quantity";
|
|
7
7
|
import { Content, ContentDescriptorRequestOptions, ContentRequestOptions, ContentSourcesRequestOptions, Descriptor, DescriptorOverrides, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup, DistinctValuesRequestOptions, ElementProperties, ElementPropertiesRequestOptions, FilterByInstancePathsHierarchyRequestOptions, FilterByTextHierarchyRequestOptions, HierarchyCompareInfo, HierarchyCompareOptions, HierarchyRequestOptions, InstanceKey, KeySet, LabelDefinition, Node, NodeKey, NodePathElement, Paged, PagedResponse, Prioritized, Ruleset, SelectClassInfo, SelectionScope, SelectionScopeRequestOptions } from "@itwin/presentation-common";
|
|
8
8
|
import { NativePlatformDefinition } from "./NativePlatform";
|
|
@@ -245,10 +245,8 @@ export declare class PresentationManager {
|
|
|
245
245
|
private _props;
|
|
246
246
|
private _nativePlatform?;
|
|
247
247
|
private _rulesets;
|
|
248
|
-
private _isOneFrontendPerBackend;
|
|
249
248
|
private _isDisposed;
|
|
250
249
|
private _disposeIModelOpenedListener?;
|
|
251
|
-
private _disposeIpcHandler?;
|
|
252
250
|
private _updatesTracker?;
|
|
253
251
|
/** Get / set active locale used for localizing presentation data */
|
|
254
252
|
activeLocale: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,
|
|
1
|
+
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAe,QAAQ,EAA2B,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EACL,OAAO,EAAE,+BAA+B,EAAgB,qBAAqB,EAAE,4BAA4B,EAA8B,UAAU,EACnJ,mBAAmB,EAAiC,0BAA0B,EAAE,2BAA2B,EAAE,iBAAiB,EAC9H,4BAA4B,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,4CAA4C,EAC9H,mCAAmC,EAAuB,oBAAoB,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,WAAW,EAC7I,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAyC,WAAW,EAAE,OAAO,EAC1I,eAAe,EAAE,cAAc,EAAE,4BAA4B,EAC9D,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACwB,wBAAwB,EAEtD,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAsB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAA+B,MAAM,2BAA2B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AO,CAAC,cAAc,EAAE,CAAC;IAInH;;;OAGG;IACU,gBAAgB,CAAC,cAAc,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAAG;QAAE,GAAG,EAAE,UAAU,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;YAKjI,OAAO;IAwBrB;;;OAGG;IACU,kBAAkB,CAAC,cAAc,EAAE,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAyB3H"}
|
|
@@ -45,7 +45,6 @@ const presentation_common_1 = require("@itwin/presentation-common");
|
|
|
45
45
|
const Constants_1 = require("./Constants");
|
|
46
46
|
const ElementPropertiesHelper_1 = require("./ElementPropertiesHelper");
|
|
47
47
|
const NativePlatform_1 = require("./NativePlatform");
|
|
48
|
-
const PresentationIpcHandler_1 = require("./PresentationIpcHandler");
|
|
49
48
|
const RulesetManager_1 = require("./RulesetManager");
|
|
50
49
|
const RulesetVariablesManager_1 = require("./RulesetVariablesManager");
|
|
51
50
|
const SelectionScopesHelper_1 = require("./SelectionScopesHelper");
|
|
@@ -143,15 +142,11 @@ class PresentationManager {
|
|
|
143
142
|
this._rulesets = new RulesetManager_1.RulesetManagerImpl(this.getNativePlatform);
|
|
144
143
|
if (this._props.enableSchemasPreload)
|
|
145
144
|
this._disposeIModelOpenedListener = core_backend_1.BriefcaseDb.onOpened.addListener(this.onIModelOpened);
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
pollInterval: props.updatesPollInterval,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
this._disposeIpcHandler = PresentationIpcHandler_1.PresentationIpcHandler.register();
|
|
145
|
+
if (core_backend_1.IpcHost.isValid && isChangeTrackingEnabled) {
|
|
146
|
+
this._updatesTracker = UpdatesTracker_1.UpdatesTracker.create({
|
|
147
|
+
nativePlatformGetter: this.getNativePlatform,
|
|
148
|
+
pollInterval: props.updatesPollInterval,
|
|
149
|
+
});
|
|
155
150
|
}
|
|
156
151
|
}
|
|
157
152
|
/**
|
|
@@ -168,8 +163,6 @@ class PresentationManager {
|
|
|
168
163
|
this._updatesTracker.dispose();
|
|
169
164
|
this._updatesTracker = undefined;
|
|
170
165
|
}
|
|
171
|
-
if (this._disposeIpcHandler)
|
|
172
|
-
this._disposeIpcHandler();
|
|
173
166
|
this._isDisposed = true;
|
|
174
167
|
}
|
|
175
168
|
/** Properties used to initialize the manager */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;AACpC,2CAA6B;AAE7B,sDAAqF;AAErF,oEAOoC;AACpC,2CAAgG;AAChG,uEAAmE;AACnE,qDAG0B;AAC1B,qEAAkE;AAClE,qDAAsE;AACtE,uEAAiG;AACjG,mEAAgE;AAChE,qDAAkD;AAClD,mCAAwC;AAExC;;;GAGG;AACH,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAYlC;AAED;;;GAGG;AACH,IAAY,kBAeX;AAfD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IACjB;;;OAGG;IACH,mCAAa,CAAA;IACb;;;OAGG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAfW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAe7B;AA0ND;;;;;GAKG;AACH,MAAa,mBAAmB;IAiB9B;;;OAGG;IACH,YAAY,KAAgC;;QAuF5C,gEAAgE;QACxD,mBAAc,GAAG,CAAC,MAAmB,EAAE,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M,CAAC,SAAS,CAAC,IAAG;IACxE,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,kBAAkB,CAAC,MAAM;QAC5C,uCAAY,MAAM,KAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,iCAAM,MAAM,CAAC,IAAI,KAAE,SAAS,EAAE,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAG,CAAC,CAAC,SAAS,IAAG;IACjI,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,kBAAkB,CAAC,MAAM;QAC5C,OAAO,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,EAAE,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,gCAAgC,GAAG,CAAC,GAAkC,EAAE,EAAE;IAC9E,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC;IACb,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,OAAO,4CAAgC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,+BAA+B,GAAG,CAAC,GAAiC,EAAE,EAAE;IAC5E,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC;IACb,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,OAAO,2CAA+B,CAAC;AACzC,CAAC,CAAC","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 * as hash from \"object-hash\";\nimport * as path from \"path\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { BriefcaseDb, IModelDb, IModelJsNative, IpcHost } from \"@itwin/core-backend\";\nimport { FormatProps, UnitSystemKey } from \"@itwin/core-quantity\";\nimport {\n Content, ContentDescriptorRequestOptions, ContentFlags, ContentRequestOptions, ContentSourcesRequestOptions, DefaultContentDisplayTypes, Descriptor,\n DescriptorOverrides, DiagnosticsOptionsWithHandler, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup,\n DistinctValuesRequestOptions, ElementProperties, ElementPropertiesRequestOptions, FilterByInstancePathsHierarchyRequestOptions,\n FilterByTextHierarchyRequestOptions, getLocalesDirectory, HierarchyCompareInfo, HierarchyCompareOptions, HierarchyRequestOptions, InstanceKey,\n KeySet, LabelDefinition, Node, NodeKey, NodePathElement, Paged, PagedResponse, PresentationError, PresentationStatus, Prioritized, Ruleset,\n SelectClassInfo, SelectionScope, SelectionScopeRequestOptions,\n} from \"@itwin/presentation-common\";\nimport { PRESENTATION_BACKEND_ASSETS_ROOT, PRESENTATION_COMMON_ASSETS_ROOT } from \"./Constants\";\nimport { buildElementProperties } from \"./ElementPropertiesHelper\";\nimport {\n createDefaultNativePlatform, NativePlatformDefinition, NativePlatformRequestTypes, NativePresentationDefaultUnitFormats,\n NativePresentationUnitSystem,\n} from \"./NativePlatform\";\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler\";\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper\";\nimport { UpdatesTracker } from \"./UpdatesTracker\";\nimport { getElementKey } from \"./Utils\";\n\n/**\n * Presentation manager working mode.\n * @public\n */\nexport enum PresentationManagerMode {\n /**\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\n * related to reacting to changes in iModels.\n */\n ReadOnly,\n\n /**\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\n * react to changes. This involves some additional work and gives slightly worse performance.\n */\n ReadWrite,\n}\n\n/**\n * Presentation hierarchy cache mode.\n * @beta\n */\nexport enum HierarchyCacheMode {\n /**\n * Hierarchy cache is created in memory.\n */\n Memory = \"memory\",\n /**\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\n * openings.\n */\n Disk = \"disk\",\n /**\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\n * and persisted in disk cache when whole hierarchy level is created.\n */\n Hybrid = \"hybrid\",\n}\n\n/**\n * Configuration for hierarchy cache.\n * @beta\n */\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\n\n/**\n * Base interface for all [[HierarchyCacheConfig]] implementations.\n * @beta\n */\nexport interface HierarchyCacheConfigBase {\n mode: HierarchyCacheMode;\n}\n\n/**\n * Configuration for in-memory hierarchy cache.\n * @beta\n */\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Memory;\n}\n\n/**\n * Configuration for persistent disk hierarchy cache.\n * @beta\n */\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Disk;\n\n /** A directory for Presentation hierarchy cache. Defaults to location of the iModel. */\n directory?: string;\n}\n\n/**\n * Configuration for the experimental hybrid hierarchy cache.\n *\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\n * alternative for cases when there are lots of simultaneous requests.\n *\n * @beta\n */\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Hybrid;\n\n /** Configuration for disk cache used to persist hierarchies. */\n disk?: DiskHierarchyCacheConfig;\n}\n\n/**\n * Configuration for content cache.\n * @public\n */\nexport interface ContentCacheConfig {\n /**\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\n *\n * Defaults to `100`.\n *\n * @alpha\n */\n size?: number;\n}\n\n/**\n * A data structure that associates unit systems with a format. The associations are used for\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\n *\n * @public\n */\nexport interface UnitSystemFormat {\n unitSystems: UnitSystemKey[];\n format: FormatProps;\n}\n\n/**\n * Properties that can be used to configure [[PresentationManager]]\n * @public\n */\nexport interface PresentationManagerProps {\n /**\n * Path overrides for presentation assets. Need to be overriden by application if it puts these assets someplace else than the default.\n *\n * By default paths to asset directories are determined during the call of [[Presentation.initialize]] using this algorithm:\n *\n * - for `presentation-backend` assets:\n *\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\n * - `assets/*\\*\\/*`\n * - `presentation-backend/{presentation-backend source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\n *\n * - for `presentation-common` assets:\n *\n * - if path of `.js` files of `presentation-common` package contain \"presentation-common\", assume the package is in `node_modules` and the directory structure is:\n * - `assets/*\\*\\/*`\n * - `presentation-common/{presentation-common source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the package's source files.\n *\n * - in both cases, if we determine that source files are not in `node_modules`, assume the backend is webpacked into a single file with assets next to it:\n * - `assets/*\\*\\/*`\n * - `{source file being executed}.js`\n *\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\n *\n * The overrides can be specified as a single path (when assets of both `presentation-backend` and `presentation-common` packages are merged into a single directory) or as an object with two separate paths for each package.\n */\n presentationAssetsRoot?: string | {\n /** Path to `presentation-backend` assets */\n backend: string;\n /** Path to `presentation-common` assets */\n common: string;\n };\n\n /**\n * A list of directories containing application's presentation rulesets.\n */\n rulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's supplemental presentation rulesets.\n */\n supplementalRulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's locale-specific localized\n * string files (in simplified i18next v3 format)\n */\n localeDirectories?: string[];\n\n /**\n * Sets the active locale to use when localizing presentation-related\n * strings. It can later be changed through [[PresentationManager.activeLocale]].\n */\n defaultLocale?: string;\n\n /**\n * Sets the active unit system to use for formatting property values with\n * units. Default presentation units are used if this is not specified. The active unit\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\n * through request options.\n */\n defaultUnitSystem?: UnitSystemKey;\n\n /**\n * A map of default unit formats to use for formatting properties that don't have a presentation format\n * in requested unit system.\n */\n defaultFormats?: {\n [phenomenon: string]: UnitSystemFormat;\n };\n\n /**\n * Should schemas preloading be enabled. If true, presentation manager listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n */\n enableSchemasPreload?: boolean;\n\n /**\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\n */\n workerThreadsCount?: number;\n\n /**\n * Presentation manager working mode. Backends that use iModels in read-write mode should\n * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.\n *\n * Defaults to [[PresentationManagerMode.ReadWrite]].\n */\n mode?: PresentationManagerMode;\n\n /**\n * The interval (in milliseconds) used to poll for presentation data changes. Only has\n * effect in read-write mode (see [[mode]]).\n *\n * @alpha\n */\n updatesPollInterval?: number;\n\n /** Options for caching. */\n caching?: {\n /**\n * Hierarchies-related caching options.\n * @beta\n */\n hierarchies?: HierarchyCacheConfig;\n\n /** Content-related caching options. */\n content?: ContentCacheConfig;\n };\n\n /**\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\n *\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\n *\n * @alpha\n */\n useMmap?: boolean | number;\n\n /**\n * An identifier which helps separate multiple presentation managers. It's\n * mostly useful in tests where multiple presentation managers can co-exist\n * and try to share the same resources, which we don't want. With this identifier\n * set, managers put their resources into id-named subdirectories.\n *\n * @internal\n */\n id?: string;\n\n /** @internal */\n addon?: NativePlatformDefinition;\n}\n\n/**\n * Backend Presentation manager which pulls the presentation data from\n * an iModel using native platform.\n *\n * @public\n */\nexport class PresentationManager {\n\n private _props: PresentationManagerProps;\n private _nativePlatform?: NativePlatformDefinition;\n private _rulesets: RulesetManager;\n private _isOneFrontendPerBackend: boolean;\n private _isDisposed: boolean;\n private _disposeIModelOpenedListener?: () => void;\n private _disposeIpcHandler?: () => void;\n private _updatesTracker?: UpdatesTracker;\n\n /** Get / set active locale used for localizing presentation data */\n public activeLocale: string | undefined;\n\n /** Get / set active unit system used to format property values with units */\n public activeUnitSystem: UnitSystemKey | undefined;\n\n /**\n * Creates an instance of PresentationManager.\n * @param props Optional configuration properties.\n */\n constructor(props?: PresentationManagerProps) {\n this._props = props ?? {};\n this._isDisposed = false;\n\n const mode = props?.mode ?? PresentationManagerMode.ReadWrite;\n const isChangeTrackingEnabled = (mode === PresentationManagerMode.ReadWrite && !!props?.updatesPollInterval);\n\n if (props && props.addon) {\n this._nativePlatform = props.addon;\n } else {\n const nativePlatformImpl = createDefaultNativePlatform({\n id: this._props.id ?? \"\",\n localeDirectories: createLocaleDirectoryList(props),\n taskAllocationsMap: createTaskAllocationsMap(props),\n mode,\n isChangeTrackingEnabled,\n cacheConfig: createCacheConfig(this._props.caching?.hierarchies),\n contentCacheSize: this._props.caching?.content?.size,\n defaultFormats: toNativeUnitFormatsMap(this._props.defaultFormats),\n useMmap: this._props.useMmap,\n });\n this._nativePlatform = new nativePlatformImpl();\n }\n\n this.setupRulesetDirectories(props);\n if (props) {\n this.activeLocale = props.defaultLocale;\n this.activeUnitSystem = props.defaultUnitSystem;\n }\n\n this._rulesets = new RulesetManagerImpl(this.getNativePlatform);\n\n if (this._props.enableSchemasPreload)\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\n\n this._isOneFrontendPerBackend = IpcHost.isValid;\n\n if (IpcHost.isValid) {\n if (isChangeTrackingEnabled) {\n this._updatesTracker = UpdatesTracker.create({\n nativePlatformGetter: this.getNativePlatform,\n pollInterval: props.updatesPollInterval!,\n });\n }\n this._disposeIpcHandler = PresentationIpcHandler.register();\n }\n }\n\n /**\n * Dispose the presentation manager. Must be called to clean up native resources.\n */\n public dispose() {\n if (this._nativePlatform) {\n this.getNativePlatform().dispose();\n this._nativePlatform = undefined;\n }\n\n if (this._disposeIModelOpenedListener)\n this._disposeIModelOpenedListener();\n\n if (this._updatesTracker) {\n this._updatesTracker.dispose();\n this._updatesTracker = undefined;\n }\n\n if (this._disposeIpcHandler)\n this._disposeIpcHandler();\n\n this._isDisposed = true;\n }\n\n /** Properties used to initialize the manager */\n public get props() { return this._props; }\n\n /**\n * Get rulesets manager\n */\n public rulesets(): RulesetManager { return this._rulesets; }\n\n /**\n * Get ruleset variables manager for specific ruleset\n * @param rulesetId Id of the ruleset to get variables manager for\n */\n public vars(rulesetId: string): RulesetVariablesManager {\n return new RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onIModelOpened = (imodel: BriefcaseDb) => {\n const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.getNativePlatform().forceLoadSchemas(imodelAddon);\n };\n\n /** @internal */\n public getNativePlatform = (): NativePlatformDefinition => {\n if (this._isDisposed)\n throw new PresentationError(PresentationStatus.NotInitialized, \"Attempting to use Presentation manager after disposal\");\n return this._nativePlatform!;\n };\n\n private setupRulesetDirectories(props?: PresentationManagerProps) {\n const supplementalRulesetDirectories = [path.join(getPresentationBackendAssetsRoot(props?.presentationAssetsRoot), \"supplemental-presentation-rules\")];\n if (props && props.supplementalRulesetDirectories) {\n props.supplementalRulesetDirectories.forEach((dir) => {\n if (-1 === supplementalRulesetDirectories.indexOf(dir))\n supplementalRulesetDirectories.push(dir);\n });\n }\n this.getNativePlatform().setupSupplementalRulesetDirectories(supplementalRulesetDirectories);\n\n const primaryRulesetDirectories = [path.join(getPresentationBackendAssetsRoot(props?.presentationAssetsRoot), \"primary-presentation-rules\")];\n if (props && props.rulesetDirectories) {\n props.rulesetDirectories.forEach((dir) => {\n if (-1 === primaryRulesetDirectories.indexOf(dir))\n primaryRulesetDirectories.push(dir);\n });\n }\n this.getNativePlatform().setupRulesetDirectories(primaryRulesetDirectories);\n }\n\n private getRulesetIdObject(rulesetOrId: Ruleset | string): { uniqueId: string, parts: { id: string, hash?: string } } {\n if (typeof rulesetOrId === \"object\") {\n const hashedId = hash.MD5(rulesetOrId);\n return {\n uniqueId: `${rulesetOrId.id}-${hashedId}`,\n parts: {\n id: rulesetOrId.id,\n hash: hashedId,\n },\n };\n }\n return { uniqueId: rulesetOrId, parts: { id: rulesetOrId } };\n }\n\n /** @internal */\n public getRulesetId(rulesetOrId: Ruleset | string) {\n return this.getRulesetIdObject(rulesetOrId).uniqueId;\n }\n\n private ensureRulesetRegistered(rulesetOrId: Ruleset | string): string {\n if (typeof rulesetOrId === \"object\") {\n const rulesetWithNativeId = { ...rulesetOrId, id: this.getRulesetId(rulesetOrId) };\n return this.rulesets().add(rulesetWithNativeId).id;\n }\n return rulesetOrId;\n }\n\n /** Registers given ruleset and replaces the ruleset with its ID in the resulting object */\n private registerRuleset<TOptions extends { rulesetOrId: Ruleset | string }>(options: TOptions) {\n const { rulesetOrId, ...strippedOptions } = options;\n const registeredRulesetId = this.ensureRulesetRegistered(rulesetOrId);\n return { rulesetId: registeredRulesetId, strippedOptions };\n }\n\n /**\n * Retrieves nodes\n * @public\n */\n public async getNodes(requestOptions: Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey>>>): Promise<Node[]> {\n const { rulesetId, strippedOptions: { parentKey, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: parentKey ? NativePlatformRequestTypes.GetChildren : NativePlatformRequestTypes.GetRootNodes,\n rulesetId,\n ...strippedOptions,\n nodeKey: parentKey,\n };\n return this.request(params, Node.listReviver);\n }\n\n /**\n * Retrieves nodes count\n * @public\n */\n public async getNodesCount(requestOptions: Prioritized<HierarchyRequestOptions<IModelDb, NodeKey>>): Promise<number> {\n const { rulesetId, strippedOptions: { parentKey, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: parentKey ? NativePlatformRequestTypes.GetChildrenCount : NativePlatformRequestTypes.GetRootNodesCount,\n rulesetId,\n ...strippedOptions,\n nodeKey: parentKey,\n };\n return this.request(params);\n }\n\n /**\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\n * TODO: Return results in pages\n * @public\n */\n public async getNodePaths(requestOptions: Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb>>): Promise<NodePathElement[]> {\n const { rulesetId, strippedOptions: { instancePaths, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetNodePaths,\n rulesetId,\n ...strippedOptions,\n paths: instancePaths.map((p) => p.map((s) => InstanceKey.toJSON(s))),\n };\n return this.request(params, NodePathElement.listReviver);\n }\n\n /**\n * Retrieves paths from root nodes to nodes containing filter text in their label.\n * TODO: Return results in pages\n * @public\n */\n public async getFilteredNodePaths(requestOptions: Prioritized<FilterByTextHierarchyRequestOptions<IModelDb>>): Promise<NodePathElement[]> {\n const { rulesetId, strippedOptions } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetFilteredNodePaths,\n rulesetId,\n ...strippedOptions,\n };\n return this.request(params, NodePathElement.listReviver);\n }\n\n /** @beta */\n public async getContentSources(requestOptions: Prioritized<ContentSourcesRequestOptions<IModelDb>>): Promise<SelectClassInfo[]> {\n const params = {\n requestId: NativePlatformRequestTypes.GetContentSources,\n rulesetId: \"ElementProperties\",\n ...requestOptions,\n };\n const reviver = (key: string, value: any) => {\n return key === \"\" ? SelectClassInfo.listFromCompressedJSON(value.sources, value.classesMap) : value;\n };\n return this.request(params, reviver);\n }\n\n /**\n * Retrieves the content descriptor which can be used to get content\n * @public\n */\n public async getContentDescriptor(requestOptions: Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet>>): Promise<Descriptor | undefined> {\n const { rulesetId, strippedOptions } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetContentDescriptor,\n rulesetId,\n ...strippedOptions,\n keys: getKeysForContentRequest(requestOptions.imodel, requestOptions.keys).toJSON(),\n };\n const reviver = (key: string, value: any) => {\n return key === \"\" ? Descriptor.fromJSON(value) : value;\n };\n return this.request(params, reviver);\n }\n\n /**\n * Retrieves the content set size based on the supplied content descriptor override\n * @public\n */\n public async getContentSetSize(requestOptions: Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet>>): Promise<number> {\n const { rulesetId, strippedOptions: { descriptor, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetContentSetSize,\n rulesetId,\n ...strippedOptions,\n keys: getKeysForContentRequest(requestOptions.imodel, requestOptions.keys).toJSON(),\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\n };\n return this.request(params);\n }\n\n /**\n * Retrieves the content based on the supplied content descriptor override.\n * @public\n */\n public async getContent(requestOptions: Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet>>>): Promise<Content | undefined> {\n const { rulesetId, strippedOptions: { descriptor, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetContent,\n rulesetId,\n ...strippedOptions,\n keys: getKeysForContentRequest(requestOptions.imodel, requestOptions.keys).toJSON(),\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\n };\n return this.request(params, Content.reviver);\n }\n\n /**\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\n * @param requestContext The client request context\n * @param requestOptions Options for the request\n * @return A promise object that returns either distinct values on success or an error string on error.\n * @public\n */\n public async getPagedDistinctValues(requestOptions: Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet>>): Promise<PagedResponse<DisplayValueGroup>> {\n const { rulesetId, strippedOptions } = this.registerRuleset(requestOptions);\n const { descriptor, keys, ...strippedOptionsNoDescriptorAndKeys } = strippedOptions;\n const params = {\n requestId: NativePlatformRequestTypes.GetPagedDistinctValues,\n rulesetId,\n ...strippedOptionsNoDescriptorAndKeys,\n keys: getKeysForContentRequest(requestOptions.imodel, keys).toJSON(),\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\n };\n const reviver = (key: string, value: any) => {\n return key === \"\" ? {\n total: value.total,\n items: value.items.map(DisplayValueGroup.fromJSON),\n } : value;\n };\n return this.request(params, reviver);\n }\n\n /**\n * Retrieves property data in a simplified format for a single element specified by ID.\n * @beta\n */\n public async getElementProperties(requestOptions: Prioritized<ElementPropertiesRequestOptions<IModelDb>>): Promise<ElementProperties | undefined> {\n const { elementId, ...optionsNoElementId } = requestOptions;\n const content = await this.getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n return buildElementProperties(content);\n }\n\n /**\n * Retrieves display label definition of specific item\n * @public\n */\n public async getDisplayLabelDefinition(requestOptions: Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>): Promise<LabelDefinition> {\n const params = {\n requestId: NativePlatformRequestTypes.GetDisplayLabel,\n ...requestOptions,\n key: InstanceKey.toJSON(requestOptions.key),\n };\n return this.request(params, LabelDefinition.reviver);\n }\n\n /**\n * Retrieves display label definitions of specific items\n * @public\n */\n public async getDisplayLabelDefinitions(requestOptions: Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>): Promise<LabelDefinition[]> {\n const concreteKeys = requestOptions.keys.map((k) => {\n if (k.className === \"BisCore:Element\")\n return getElementKey(requestOptions.imodel, k.id);\n return k;\n }).filter<InstanceKey>((k): k is InstanceKey => !!k);\n const contentRequestOptions: ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet> = {\n ...requestOptions,\n rulesetOrId: \"RulesDrivenECPresentationManager_RulesetId_DisplayLabel\",\n descriptor: {\n displayType: DefaultContentDisplayTypes.List,\n contentFlags: ContentFlags.ShowLabels | ContentFlags.NoFields,\n },\n keys: new KeySet(concreteKeys),\n };\n const content = await this.getContent(contentRequestOptions);\n return concreteKeys.map((key) => {\n const item = content ? content.contentSet.find((it) => it.primaryKeys.length > 0 && InstanceKey.compare(it.primaryKeys[0], key) === 0) : undefined;\n if (!item)\n return { displayValue: \"\", rawValue: \"\", typeName: \"\" };\n return item.label;\n });\n }\n\n /**\n * Retrieves available selection scopes.\n * @public\n */\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb>): Promise<SelectionScope[]> {\n return SelectionScopesHelper.getSelectionScopes();\n }\n\n /**\n * Computes selection set based on provided selection scope.\n * @public\n */\n public async computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[], scopeId: string }): Promise<KeySet> {\n const { ids, scopeId, ...opts } = requestOptions; // eslint-disable-line @typescript-eslint/no-unused-vars\n return SelectionScopesHelper.computeSelection(opts, ids, scopeId);\n }\n\n private async request<TParams extends { diagnostics?: DiagnosticsOptionsWithHandler, requestId: string, imodel: IModelDb, locale?: string, unitSystem?: UnitSystemKey }, TResult>(params: TParams, reviver?: (key: string, value: any) => any): Promise<TResult> {\n const { requestId, imodel, locale, unitSystem, diagnostics, ...strippedParams } = params;\n const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);\n const nativeRequestParams: any = {\n requestId,\n params: {\n locale: normalizeLocale(locale ?? this.activeLocale),\n unitSystem: toOptionalNativeUnitSystem(unitSystem ?? this.activeUnitSystem),\n ...strippedParams,\n },\n };\n\n let diagnosticsListener;\n if (diagnostics) {\n const { handler: tempDiagnosticsListener, ...diagnosticsOptions } = diagnostics;\n diagnosticsListener = tempDiagnosticsListener;\n nativeRequestParams.params.diagnostics = diagnosticsOptions;\n }\n\n const response = await this.getNativePlatform().handleRequest(imodelAddon, JSON.stringify(nativeRequestParams));\n diagnosticsListener && response.diagnostics && diagnosticsListener([response.diagnostics]);\n return JSON.parse(response.result, reviver);\n }\n\n /**\n * Compares two hierarchies specified in the request options\n * @public\n */\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables)\n return { changes: [] };\n\n const { strippedOptions: { prev, rulesetVariables, ...options } } = this.registerRuleset(requestOptions);\n\n const currRulesetId = this.getRulesetIdObject(requestOptions.rulesetOrId);\n const prevRulesetId = prev.rulesetOrId ? this.getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\n if (prevRulesetId.parts.id !== currRulesetId.parts.id)\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\n\n const currRulesetVariables = rulesetVariables ?? [];\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\n\n const params = {\n requestId: NativePlatformRequestTypes.CompareHierarchies,\n ...options,\n prevRulesetId: prevRulesetId.uniqueId,\n currRulesetId: currRulesetId.uniqueId,\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\n currRulesetVariables: JSON.stringify(currRulesetVariables),\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\n };\n return this.request(params, (key: string, value: any) => ((key === \"\") ? HierarchyCompareInfo.fromJSON(value) : value));\n }\n}\n\nconst getKeysForContentRequest = (imodel: IModelDb, keys: KeySet): KeySet => {\n const elementClassName = \"BisCore:Element\";\n const instanceKeys = keys.instanceKeys;\n if (!instanceKeys.has(elementClassName))\n return keys;\n\n const elementIds = instanceKeys.get(elementClassName)!;\n const keyset = new KeySet();\n keyset.add(keys);\n elementIds.forEach((elementId) => {\n const concreteKey = getElementKey(imodel, elementId);\n if (concreteKey) {\n keyset.delete({ className: elementClassName, id: elementId });\n keyset.add(concreteKey);\n }\n });\n return keyset;\n};\n\nconst createContentDescriptorOverrides = (descriptorOrOverrides: Descriptor | DescriptorOverrides): DescriptorOverrides => {\n if (descriptorOrOverrides instanceof Descriptor)\n return descriptorOrOverrides.createDescriptorOverrides();\n return descriptorOrOverrides;\n};\n\nconst createLocaleDirectoryList = (props?: PresentationManagerProps) => {\n const localeDirectories = [getLocalesDirectory(getPresentationCommonAssetsRoot(props?.presentationAssetsRoot))];\n if (props && props.localeDirectories) {\n props.localeDirectories.forEach((dir) => {\n if (-1 === localeDirectories.indexOf(dir))\n localeDirectories.push(dir);\n });\n }\n return localeDirectories;\n};\n\nconst createTaskAllocationsMap = (props?: PresentationManagerProps) => {\n const count = props?.workerThreadsCount ?? 2;\n return {\n [Number.MAX_SAFE_INTEGER]: count,\n };\n};\n\nconst normalizeLocale = (locale?: string) => {\n if (!locale)\n return undefined;\n return locale.toLocaleLowerCase();\n};\n\nconst normalizeDirectory = (directory?: string) => {\n return directory ? path.resolve(directory) : \"\";\n};\n\nconst toNativeUnitSystem = (unitSystem: UnitSystemKey) => {\n switch (unitSystem) {\n case \"imperial\": return NativePresentationUnitSystem.BritishImperial;\n case \"metric\": return NativePresentationUnitSystem.Metric;\n case \"usCustomary\": return NativePresentationUnitSystem.UsCustomary;\n case \"usSurvey\": return NativePresentationUnitSystem.UsSurvey;\n }\n};\n\nconst toOptionalNativeUnitSystem = (unitSystem: UnitSystemKey | undefined) => {\n return unitSystem ? toNativeUnitSystem(unitSystem) : undefined;\n};\n\nconst toNativeUnitFormatsMap = (map: { [phenomenon: string]: UnitSystemFormat } | undefined) => {\n if (!map)\n return undefined;\n\n const nativeFormatsMap: NativePresentationDefaultUnitFormats = {};\n Object.keys(map).forEach((phenomenon) => {\n const unitSystemsFormat = map[phenomenon];\n nativeFormatsMap[phenomenon] = {\n unitSystems: unitSystemsFormat.unitSystems.map(toNativeUnitSystem),\n format: unitSystemsFormat.format,\n };\n });\n return nativeFormatsMap;\n};\n\nconst createCacheConfig = (config?: HierarchyCacheConfig): IModelJsNative.ECPresentationHierarchyCacheConfig => {\n if (config?.mode === HierarchyCacheMode.Disk)\n return { ...config, directory: normalizeDirectory(config.directory) };\n if (config?.mode === HierarchyCacheMode.Hybrid)\n return { ...config, disk: config.disk ? { ...config.disk, directory: normalizeDirectory(config.disk.directory) } : undefined };\n if (config?.mode === HierarchyCacheMode.Memory)\n return config;\n return { mode: HierarchyCacheMode.Disk, directory: \"\" };\n};\n\nconst getPresentationBackendAssetsRoot = (ovr?: string | { backend: string }) => {\n if (typeof ovr === \"string\")\n return ovr;\n if (typeof ovr === \"object\")\n return ovr.backend;\n return PRESENTATION_BACKEND_ASSETS_ROOT;\n};\n\nconst getPresentationCommonAssetsRoot = (ovr?: string | { common: string }) => {\n if (typeof ovr === \"string\")\n return ovr;\n if (typeof ovr === \"object\")\n return ovr.common;\n return PRESENTATION_COMMON_ASSETS_ROOT;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"PresentationManager.js","sourceRoot":"","sources":["../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kDAAoC;AACpC,2CAA6B;AAC7B,sDAAqF;AAGrF,oEAOoC;AACpC,2CAAgG;AAChG,uEAAmE;AACnE,qDAG0B;AAC1B,qDAAsE;AACtE,uEAAiG;AACjG,mEAAgE;AAChE,qDAAkD;AAClD,mCAAwC;AAExC;;;GAGG;AACH,IAAY,uBAYX;AAZD,WAAY,uBAAuB;IACjC;;;OAGG;IACH,6EAAQ,CAAA;IAER;;;OAGG;IACH,+EAAS,CAAA;AACX,CAAC,EAZW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAYlC;AAED;;;GAGG;AACH,IAAY,kBAeX;AAfD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,uCAAiB,CAAA;IACjB;;;OAGG;IACH,mCAAa,CAAA;IACb;;;OAGG;IACH,uCAAiB,CAAA;AACnB,CAAC,EAfW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAe7B;AA0ND;;;;;GAKG;AACH,MAAa,mBAAmB;IAe9B;;;OAGG;IACH,YAAY,KA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AM,CAAC,IAAI,CAAC,CAAC,iCAAM,MAAM,CAAC,IAAI,KAAE,SAAS,EAAE,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAG,CAAC,CAAC,SAAS,IAAG;IACjI,IAAI,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,MAAK,kBAAkB,CAAC,MAAM;QAC5C,OAAO,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,EAAE,kBAAkB,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,gCAAgC,GAAG,CAAC,GAAkC,EAAE,EAAE;IAC9E,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC;IACb,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC,OAAO,CAAC;IACrB,OAAO,4CAAgC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,+BAA+B,GAAG,CAAC,GAAiC,EAAE,EAAE;IAC5E,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC;IACb,IAAI,OAAO,GAAG,KAAK,QAAQ;QACzB,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,OAAO,2CAA+B,CAAC;AACzC,CAAC,CAAC","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 * as hash from \"object-hash\";\nimport * as path from \"path\";\nimport { BriefcaseDb, IModelDb, IModelJsNative, IpcHost } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { FormatProps, UnitSystemKey } from \"@itwin/core-quantity\";\nimport {\n Content, ContentDescriptorRequestOptions, ContentFlags, ContentRequestOptions, ContentSourcesRequestOptions, DefaultContentDisplayTypes, Descriptor,\n DescriptorOverrides, DiagnosticsOptionsWithHandler, DisplayLabelRequestOptions, DisplayLabelsRequestOptions, DisplayValueGroup,\n DistinctValuesRequestOptions, ElementProperties, ElementPropertiesRequestOptions, FilterByInstancePathsHierarchyRequestOptions,\n FilterByTextHierarchyRequestOptions, getLocalesDirectory, HierarchyCompareInfo, HierarchyCompareOptions, HierarchyRequestOptions, InstanceKey,\n KeySet, LabelDefinition, Node, NodeKey, NodePathElement, Paged, PagedResponse, PresentationError, PresentationStatus, Prioritized, Ruleset,\n SelectClassInfo, SelectionScope, SelectionScopeRequestOptions,\n} from \"@itwin/presentation-common\";\nimport { PRESENTATION_BACKEND_ASSETS_ROOT, PRESENTATION_COMMON_ASSETS_ROOT } from \"./Constants\";\nimport { buildElementProperties } from \"./ElementPropertiesHelper\";\nimport {\n createDefaultNativePlatform, NativePlatformDefinition, NativePlatformRequestTypes, NativePresentationDefaultUnitFormats,\n NativePresentationUnitSystem,\n} from \"./NativePlatform\";\nimport { RulesetManager, RulesetManagerImpl } from \"./RulesetManager\";\nimport { RulesetVariablesManager, RulesetVariablesManagerImpl } from \"./RulesetVariablesManager\";\nimport { SelectionScopesHelper } from \"./SelectionScopesHelper\";\nimport { UpdatesTracker } from \"./UpdatesTracker\";\nimport { getElementKey } from \"./Utils\";\n\n/**\n * Presentation manager working mode.\n * @public\n */\nexport enum PresentationManagerMode {\n /**\n * Presentation manager assumes iModels are opened in read-only mode and avoids doing some work\n * related to reacting to changes in iModels.\n */\n ReadOnly,\n\n /**\n * Presentation manager assumes iModels are opened in read-write mode and it may need to\n * react to changes. This involves some additional work and gives slightly worse performance.\n */\n ReadWrite,\n}\n\n/**\n * Presentation hierarchy cache mode.\n * @beta\n */\nexport enum HierarchyCacheMode {\n /**\n * Hierarchy cache is created in memory.\n */\n Memory = \"memory\",\n /**\n * Hierarchy cache is created on disk. In this mode hierarchy cache is persisted between iModel\n * openings.\n */\n Disk = \"disk\",\n /**\n * Hierarchy cache is created on disk. In this mode everything is cached in memory while creating hierarchy level\n * and persisted in disk cache when whole hierarchy level is created.\n */\n Hybrid = \"hybrid\",\n}\n\n/**\n * Configuration for hierarchy cache.\n * @beta\n */\nexport type HierarchyCacheConfig = MemoryHierarchyCacheConfig | DiskHierarchyCacheConfig | HybridCacheConfig;\n\n/**\n * Base interface for all [[HierarchyCacheConfig]] implementations.\n * @beta\n */\nexport interface HierarchyCacheConfigBase {\n mode: HierarchyCacheMode;\n}\n\n/**\n * Configuration for in-memory hierarchy cache.\n * @beta\n */\nexport interface MemoryHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Memory;\n}\n\n/**\n * Configuration for persistent disk hierarchy cache.\n * @beta\n */\nexport interface DiskHierarchyCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Disk;\n\n /** A directory for Presentation hierarchy cache. Defaults to location of the iModel. */\n directory?: string;\n}\n\n/**\n * Configuration for the experimental hybrid hierarchy cache.\n *\n * Hybrid cache uses a combination of in-memory and disk caches, which should make it a better\n * alternative for cases when there are lots of simultaneous requests.\n *\n * @beta\n */\nexport interface HybridCacheConfig extends HierarchyCacheConfigBase {\n mode: HierarchyCacheMode.Hybrid;\n\n /** Configuration for disk cache used to persist hierarchies. */\n disk?: DiskHierarchyCacheConfig;\n}\n\n/**\n * Configuration for content cache.\n * @public\n */\nexport interface ContentCacheConfig {\n /**\n * Maximum number of content descriptors cached in memory for quicker paged content requests.\n *\n * Defaults to `100`.\n *\n * @alpha\n */\n size?: number;\n}\n\n/**\n * A data structure that associates unit systems with a format. The associations are used for\n * assigning default unit formats for specific phenomenons (see [[PresentationManagerProps.defaultFormats]]).\n *\n * @public\n */\nexport interface UnitSystemFormat {\n unitSystems: UnitSystemKey[];\n format: FormatProps;\n}\n\n/**\n * Properties that can be used to configure [[PresentationManager]]\n * @public\n */\nexport interface PresentationManagerProps {\n /**\n * Path overrides for presentation assets. Need to be overriden by application if it puts these assets someplace else than the default.\n *\n * By default paths to asset directories are determined during the call of [[Presentation.initialize]] using this algorithm:\n *\n * - for `presentation-backend` assets:\n *\n * - if path of `.js` file that contains [[PresentationManager]] definition contains \"presentation-backend\", assume the package is in `node_modules` and the directory structure is:\n * - `assets/*\\*\\/*`\n * - `presentation-backend/{presentation-backend source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the JS file being executed.\n *\n * - for `presentation-common` assets:\n *\n * - if path of `.js` files of `presentation-common` package contain \"presentation-common\", assume the package is in `node_modules` and the directory structure is:\n * - `assets/*\\*\\/*`\n * - `presentation-common/{presentation-common source files}`\n *\n * which means the assets can be found through a relative path `../assets/` from the package's source files.\n *\n * - in both cases, if we determine that source files are not in `node_modules`, assume the backend is webpacked into a single file with assets next to it:\n * - `assets/*\\*\\/*`\n * - `{source file being executed}.js`\n *\n * which means the assets can be found through a relative path `./assets/` from the `{source file being executed}`.\n *\n * The overrides can be specified as a single path (when assets of both `presentation-backend` and `presentation-common` packages are merged into a single directory) or as an object with two separate paths for each package.\n */\n presentationAssetsRoot?: string | {\n /** Path to `presentation-backend` assets */\n backend: string;\n /** Path to `presentation-common` assets */\n common: string;\n };\n\n /**\n * A list of directories containing application's presentation rulesets.\n */\n rulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's supplemental presentation rulesets.\n */\n supplementalRulesetDirectories?: string[];\n\n /**\n * A list of directories containing application's locale-specific localized\n * string files (in simplified i18next v3 format)\n */\n localeDirectories?: string[];\n\n /**\n * Sets the active locale to use when localizing presentation-related\n * strings. It can later be changed through [[PresentationManager.activeLocale]].\n */\n defaultLocale?: string;\n\n /**\n * Sets the active unit system to use for formatting property values with\n * units. Default presentation units are used if this is not specified. The active unit\n * system can later be changed through [[PresentationManager.activeUnitSystem]] or overriden for each request\n * through request options.\n */\n defaultUnitSystem?: UnitSystemKey;\n\n /**\n * A map of default unit formats to use for formatting properties that don't have a presentation format\n * in requested unit system.\n */\n defaultFormats?: {\n [phenomenon: string]: UnitSystemFormat;\n };\n\n /**\n * Should schemas preloading be enabled. If true, presentation manager listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n */\n enableSchemasPreload?: boolean;\n\n /**\n * A number of worker threads to use for handling presentation requests. Defaults to `2`.\n */\n workerThreadsCount?: number;\n\n /**\n * Presentation manager working mode. Backends that use iModels in read-write mode should\n * use `ReadWrite`, others might want to set to `ReadOnly` for better performance.\n *\n * Defaults to [[PresentationManagerMode.ReadWrite]].\n */\n mode?: PresentationManagerMode;\n\n /**\n * The interval (in milliseconds) used to poll for presentation data changes. Only has\n * effect in read-write mode (see [[mode]]).\n *\n * @alpha\n */\n updatesPollInterval?: number;\n\n /** Options for caching. */\n caching?: {\n /**\n * Hierarchies-related caching options.\n * @beta\n */\n hierarchies?: HierarchyCacheConfig;\n\n /** Content-related caching options. */\n content?: ContentCacheConfig;\n };\n\n /**\n * Use [SQLite's Memory-Mapped I/O](https://sqlite.org/mmap.html) for worker connections. This mode improves performance of handling\n * requests with high I/O intensity, e.g. filtering large tables on non-indexed columns. No downsides have been noticed.\n *\n * Set to a falsy value to turn off. `true` for memory-mapping the whole iModel. Number value for memory-mapping the specified amount of bytes.\n *\n * @alpha\n */\n useMmap?: boolean | number;\n\n /**\n * An identifier which helps separate multiple presentation managers. It's\n * mostly useful in tests where multiple presentation managers can co-exist\n * and try to share the same resources, which we don't want. With this identifier\n * set, managers put their resources into id-named subdirectories.\n *\n * @internal\n */\n id?: string;\n\n /** @internal */\n addon?: NativePlatformDefinition;\n}\n\n/**\n * Backend Presentation manager which pulls the presentation data from\n * an iModel using native platform.\n *\n * @public\n */\nexport class PresentationManager {\n\n private _props: PresentationManagerProps;\n private _nativePlatform?: NativePlatformDefinition;\n private _rulesets: RulesetManager;\n private _isDisposed: boolean;\n private _disposeIModelOpenedListener?: () => void;\n private _updatesTracker?: UpdatesTracker;\n\n /** Get / set active locale used for localizing presentation data */\n public activeLocale: string | undefined;\n\n /** Get / set active unit system used to format property values with units */\n public activeUnitSystem: UnitSystemKey | undefined;\n\n /**\n * Creates an instance of PresentationManager.\n * @param props Optional configuration properties.\n */\n constructor(props?: PresentationManagerProps) {\n this._props = props ?? {};\n this._isDisposed = false;\n\n const mode = props?.mode ?? PresentationManagerMode.ReadWrite;\n const isChangeTrackingEnabled = (mode === PresentationManagerMode.ReadWrite && !!props?.updatesPollInterval);\n\n if (props && props.addon) {\n this._nativePlatform = props.addon;\n } else {\n const nativePlatformImpl = createDefaultNativePlatform({\n id: this._props.id ?? \"\",\n localeDirectories: createLocaleDirectoryList(props),\n taskAllocationsMap: createTaskAllocationsMap(props),\n mode,\n isChangeTrackingEnabled,\n cacheConfig: createCacheConfig(this._props.caching?.hierarchies),\n contentCacheSize: this._props.caching?.content?.size,\n defaultFormats: toNativeUnitFormatsMap(this._props.defaultFormats),\n useMmap: this._props.useMmap,\n });\n this._nativePlatform = new nativePlatformImpl();\n }\n\n this.setupRulesetDirectories(props);\n if (props) {\n this.activeLocale = props.defaultLocale;\n this.activeUnitSystem = props.defaultUnitSystem;\n }\n\n this._rulesets = new RulesetManagerImpl(this.getNativePlatform);\n\n if (this._props.enableSchemasPreload)\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\n\n if (IpcHost.isValid && isChangeTrackingEnabled) {\n this._updatesTracker = UpdatesTracker.create({\n nativePlatformGetter: this.getNativePlatform,\n pollInterval: props.updatesPollInterval!,\n });\n }\n }\n\n /**\n * Dispose the presentation manager. Must be called to clean up native resources.\n */\n public dispose() {\n if (this._nativePlatform) {\n this.getNativePlatform().dispose();\n this._nativePlatform = undefined;\n }\n\n if (this._disposeIModelOpenedListener)\n this._disposeIModelOpenedListener();\n\n if (this._updatesTracker) {\n this._updatesTracker.dispose();\n this._updatesTracker = undefined;\n }\n\n this._isDisposed = true;\n }\n\n /** Properties used to initialize the manager */\n public get props() { return this._props; }\n\n /**\n * Get rulesets manager\n */\n public rulesets(): RulesetManager { return this._rulesets; }\n\n /**\n * Get ruleset variables manager for specific ruleset\n * @param rulesetId Id of the ruleset to get variables manager for\n */\n public vars(rulesetId: string): RulesetVariablesManager {\n return new RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);\n }\n\n // eslint-disable-next-line @typescript-eslint/naming-convention\n private onIModelOpened = (imodel: BriefcaseDb) => {\n const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.getNativePlatform().forceLoadSchemas(imodelAddon);\n };\n\n /** @internal */\n public getNativePlatform = (): NativePlatformDefinition => {\n if (this._isDisposed)\n throw new PresentationError(PresentationStatus.NotInitialized, \"Attempting to use Presentation manager after disposal\");\n return this._nativePlatform!;\n };\n\n private setupRulesetDirectories(props?: PresentationManagerProps) {\n const supplementalRulesetDirectories = [path.join(getPresentationBackendAssetsRoot(props?.presentationAssetsRoot), \"supplemental-presentation-rules\")];\n if (props && props.supplementalRulesetDirectories) {\n props.supplementalRulesetDirectories.forEach((dir) => {\n if (-1 === supplementalRulesetDirectories.indexOf(dir))\n supplementalRulesetDirectories.push(dir);\n });\n }\n this.getNativePlatform().setupSupplementalRulesetDirectories(supplementalRulesetDirectories);\n\n const primaryRulesetDirectories = [path.join(getPresentationBackendAssetsRoot(props?.presentationAssetsRoot), \"primary-presentation-rules\")];\n if (props && props.rulesetDirectories) {\n props.rulesetDirectories.forEach((dir) => {\n if (-1 === primaryRulesetDirectories.indexOf(dir))\n primaryRulesetDirectories.push(dir);\n });\n }\n this.getNativePlatform().setupRulesetDirectories(primaryRulesetDirectories);\n }\n\n private getRulesetIdObject(rulesetOrId: Ruleset | string): { uniqueId: string, parts: { id: string, hash?: string } } {\n if (typeof rulesetOrId === \"object\") {\n const hashedId = hash.MD5(rulesetOrId);\n return {\n uniqueId: `${rulesetOrId.id}-${hashedId}`,\n parts: {\n id: rulesetOrId.id,\n hash: hashedId,\n },\n };\n }\n return { uniqueId: rulesetOrId, parts: { id: rulesetOrId } };\n }\n\n /** @internal */\n public getRulesetId(rulesetOrId: Ruleset | string) {\n return this.getRulesetIdObject(rulesetOrId).uniqueId;\n }\n\n private ensureRulesetRegistered(rulesetOrId: Ruleset | string): string {\n if (typeof rulesetOrId === \"object\") {\n const rulesetWithNativeId = { ...rulesetOrId, id: this.getRulesetId(rulesetOrId) };\n return this.rulesets().add(rulesetWithNativeId).id;\n }\n return rulesetOrId;\n }\n\n /** Registers given ruleset and replaces the ruleset with its ID in the resulting object */\n private registerRuleset<TOptions extends { rulesetOrId: Ruleset | string }>(options: TOptions) {\n const { rulesetOrId, ...strippedOptions } = options;\n const registeredRulesetId = this.ensureRulesetRegistered(rulesetOrId);\n return { rulesetId: registeredRulesetId, strippedOptions };\n }\n\n /**\n * Retrieves nodes\n * @public\n */\n public async getNodes(requestOptions: Prioritized<Paged<HierarchyRequestOptions<IModelDb, NodeKey>>>): Promise<Node[]> {\n const { rulesetId, strippedOptions: { parentKey, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: parentKey ? NativePlatformRequestTypes.GetChildren : NativePlatformRequestTypes.GetRootNodes,\n rulesetId,\n ...strippedOptions,\n nodeKey: parentKey,\n };\n return this.request(params, Node.listReviver);\n }\n\n /**\n * Retrieves nodes count\n * @public\n */\n public async getNodesCount(requestOptions: Prioritized<HierarchyRequestOptions<IModelDb, NodeKey>>): Promise<number> {\n const { rulesetId, strippedOptions: { parentKey, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: parentKey ? NativePlatformRequestTypes.GetChildrenCount : NativePlatformRequestTypes.GetRootNodesCount,\n rulesetId,\n ...strippedOptions,\n nodeKey: parentKey,\n };\n return this.request(params);\n }\n\n /**\n * Retrieves paths from root nodes to children nodes according to specified instance key paths. Intersecting paths will be merged.\n * TODO: Return results in pages\n * @public\n */\n public async getNodePaths(requestOptions: Prioritized<FilterByInstancePathsHierarchyRequestOptions<IModelDb>>): Promise<NodePathElement[]> {\n const { rulesetId, strippedOptions: { instancePaths, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetNodePaths,\n rulesetId,\n ...strippedOptions,\n paths: instancePaths.map((p) => p.map((s) => InstanceKey.toJSON(s))),\n };\n return this.request(params, NodePathElement.listReviver);\n }\n\n /**\n * Retrieves paths from root nodes to nodes containing filter text in their label.\n * TODO: Return results in pages\n * @public\n */\n public async getFilteredNodePaths(requestOptions: Prioritized<FilterByTextHierarchyRequestOptions<IModelDb>>): Promise<NodePathElement[]> {\n const { rulesetId, strippedOptions } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetFilteredNodePaths,\n rulesetId,\n ...strippedOptions,\n };\n return this.request(params, NodePathElement.listReviver);\n }\n\n /** @beta */\n public async getContentSources(requestOptions: Prioritized<ContentSourcesRequestOptions<IModelDb>>): Promise<SelectClassInfo[]> {\n const params = {\n requestId: NativePlatformRequestTypes.GetContentSources,\n rulesetId: \"ElementProperties\",\n ...requestOptions,\n };\n const reviver = (key: string, value: any) => {\n return key === \"\" ? SelectClassInfo.listFromCompressedJSON(value.sources, value.classesMap) : value;\n };\n return this.request(params, reviver);\n }\n\n /**\n * Retrieves the content descriptor which can be used to get content\n * @public\n */\n public async getContentDescriptor(requestOptions: Prioritized<ContentDescriptorRequestOptions<IModelDb, KeySet>>): Promise<Descriptor | undefined> {\n const { rulesetId, strippedOptions } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetContentDescriptor,\n rulesetId,\n ...strippedOptions,\n keys: getKeysForContentRequest(requestOptions.imodel, requestOptions.keys).toJSON(),\n };\n const reviver = (key: string, value: any) => {\n return key === \"\" ? Descriptor.fromJSON(value) : value;\n };\n return this.request(params, reviver);\n }\n\n /**\n * Retrieves the content set size based on the supplied content descriptor override\n * @public\n */\n public async getContentSetSize(requestOptions: Prioritized<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet>>): Promise<number> {\n const { rulesetId, strippedOptions: { descriptor, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetContentSetSize,\n rulesetId,\n ...strippedOptions,\n keys: getKeysForContentRequest(requestOptions.imodel, requestOptions.keys).toJSON(),\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\n };\n return this.request(params);\n }\n\n /**\n * Retrieves the content based on the supplied content descriptor override.\n * @public\n */\n public async getContent(requestOptions: Prioritized<Paged<ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet>>>): Promise<Content | undefined> {\n const { rulesetId, strippedOptions: { descriptor, ...strippedOptions } } = this.registerRuleset(requestOptions);\n const params = {\n requestId: NativePlatformRequestTypes.GetContent,\n rulesetId,\n ...strippedOptions,\n keys: getKeysForContentRequest(requestOptions.imodel, requestOptions.keys).toJSON(),\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\n };\n return this.request(params, Content.reviver);\n }\n\n /**\n * Retrieves distinct values of specific field from the content based on the supplied content descriptor override.\n * @param requestContext The client request context\n * @param requestOptions Options for the request\n * @return A promise object that returns either distinct values on success or an error string on error.\n * @public\n */\n public async getPagedDistinctValues(requestOptions: Prioritized<DistinctValuesRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet>>): Promise<PagedResponse<DisplayValueGroup>> {\n const { rulesetId, strippedOptions } = this.registerRuleset(requestOptions);\n const { descriptor, keys, ...strippedOptionsNoDescriptorAndKeys } = strippedOptions;\n const params = {\n requestId: NativePlatformRequestTypes.GetPagedDistinctValues,\n rulesetId,\n ...strippedOptionsNoDescriptorAndKeys,\n keys: getKeysForContentRequest(requestOptions.imodel, keys).toJSON(),\n descriptorOverrides: createContentDescriptorOverrides(descriptor),\n };\n const reviver = (key: string, value: any) => {\n return key === \"\" ? {\n total: value.total,\n items: value.items.map(DisplayValueGroup.fromJSON),\n } : value;\n };\n return this.request(params, reviver);\n }\n\n /**\n * Retrieves property data in a simplified format for a single element specified by ID.\n * @beta\n */\n public async getElementProperties(requestOptions: Prioritized<ElementPropertiesRequestOptions<IModelDb>>): Promise<ElementProperties | undefined> {\n const { elementId, ...optionsNoElementId } = requestOptions;\n const content = await this.getContent({\n ...optionsNoElementId,\n descriptor: {\n displayType: DefaultContentDisplayTypes.PropertyPane,\n contentFlags: ContentFlags.ShowLabels,\n },\n rulesetOrId: \"ElementProperties\",\n keys: new KeySet([{ className: \"BisCore:Element\", id: elementId }]),\n });\n return buildElementProperties(content);\n }\n\n /**\n * Retrieves display label definition of specific item\n * @public\n */\n public async getDisplayLabelDefinition(requestOptions: Prioritized<DisplayLabelRequestOptions<IModelDb, InstanceKey>>): Promise<LabelDefinition> {\n const params = {\n requestId: NativePlatformRequestTypes.GetDisplayLabel,\n ...requestOptions,\n key: InstanceKey.toJSON(requestOptions.key),\n };\n return this.request(params, LabelDefinition.reviver);\n }\n\n /**\n * Retrieves display label definitions of specific items\n * @public\n */\n public async getDisplayLabelDefinitions(requestOptions: Prioritized<Paged<DisplayLabelsRequestOptions<IModelDb, InstanceKey>>>): Promise<LabelDefinition[]> {\n const concreteKeys = requestOptions.keys.map((k) => {\n if (k.className === \"BisCore:Element\")\n return getElementKey(requestOptions.imodel, k.id);\n return k;\n }).filter<InstanceKey>((k): k is InstanceKey => !!k);\n const contentRequestOptions: ContentRequestOptions<IModelDb, Descriptor | DescriptorOverrides, KeySet> = {\n ...requestOptions,\n rulesetOrId: \"RulesDrivenECPresentationManager_RulesetId_DisplayLabel\",\n descriptor: {\n displayType: DefaultContentDisplayTypes.List,\n contentFlags: ContentFlags.ShowLabels | ContentFlags.NoFields,\n },\n keys: new KeySet(concreteKeys),\n };\n const content = await this.getContent(contentRequestOptions);\n return concreteKeys.map((key) => {\n const item = content ? content.contentSet.find((it) => it.primaryKeys.length > 0 && InstanceKey.compare(it.primaryKeys[0], key) === 0) : undefined;\n if (!item)\n return { displayValue: \"\", rawValue: \"\", typeName: \"\" };\n return item.label;\n });\n }\n\n /**\n * Retrieves available selection scopes.\n * @public\n */\n public async getSelectionScopes(_requestOptions: SelectionScopeRequestOptions<IModelDb>): Promise<SelectionScope[]> {\n return SelectionScopesHelper.getSelectionScopes();\n }\n\n /**\n * Computes selection set based on provided selection scope.\n * @public\n */\n public async computeSelection(requestOptions: SelectionScopeRequestOptions<IModelDb> & { ids: Id64String[], scopeId: string }): Promise<KeySet> {\n const { ids, scopeId, ...opts } = requestOptions; // eslint-disable-line @typescript-eslint/no-unused-vars\n return SelectionScopesHelper.computeSelection(opts, ids, scopeId);\n }\n\n private async request<TParams extends { diagnostics?: DiagnosticsOptionsWithHandler, requestId: string, imodel: IModelDb, locale?: string, unitSystem?: UnitSystemKey }, TResult>(params: TParams, reviver?: (key: string, value: any) => any): Promise<TResult> {\n const { requestId, imodel, locale, unitSystem, diagnostics, ...strippedParams } = params;\n const imodelAddon = this.getNativePlatform().getImodelAddon(imodel);\n const nativeRequestParams: any = {\n requestId,\n params: {\n locale: normalizeLocale(locale ?? this.activeLocale),\n unitSystem: toOptionalNativeUnitSystem(unitSystem ?? this.activeUnitSystem),\n ...strippedParams,\n },\n };\n\n let diagnosticsListener;\n if (diagnostics) {\n const { handler: tempDiagnosticsListener, ...diagnosticsOptions } = diagnostics;\n diagnosticsListener = tempDiagnosticsListener;\n nativeRequestParams.params.diagnostics = diagnosticsOptions;\n }\n\n const response = await this.getNativePlatform().handleRequest(imodelAddon, JSON.stringify(nativeRequestParams));\n diagnosticsListener && response.diagnostics && diagnosticsListener([response.diagnostics]);\n return JSON.parse(response.result, reviver);\n }\n\n /**\n * Compares two hierarchies specified in the request options\n * @public\n */\n public async compareHierarchies(requestOptions: HierarchyCompareOptions<IModelDb, NodeKey>): Promise<HierarchyCompareInfo> {\n if (!requestOptions.prev.rulesetOrId && !requestOptions.prev.rulesetVariables)\n return { changes: [] };\n\n const { strippedOptions: { prev, rulesetVariables, ...options } } = this.registerRuleset(requestOptions);\n\n const currRulesetId = this.getRulesetIdObject(requestOptions.rulesetOrId);\n const prevRulesetId = prev.rulesetOrId ? this.getRulesetIdObject(prev.rulesetOrId) : currRulesetId;\n if (prevRulesetId.parts.id !== currRulesetId.parts.id)\n throw new PresentationError(PresentationStatus.InvalidArgument, \"Can't compare rulesets with different IDs\");\n\n const currRulesetVariables = rulesetVariables ?? [];\n const prevRulesetVariables = prev.rulesetVariables ?? currRulesetVariables;\n\n const params = {\n requestId: NativePlatformRequestTypes.CompareHierarchies,\n ...options,\n prevRulesetId: prevRulesetId.uniqueId,\n currRulesetId: currRulesetId.uniqueId,\n prevRulesetVariables: JSON.stringify(prevRulesetVariables),\n currRulesetVariables: JSON.stringify(currRulesetVariables),\n expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),\n };\n return this.request(params, (key: string, value: any) => ((key === \"\") ? HierarchyCompareInfo.fromJSON(value) : value));\n }\n}\n\nconst getKeysForContentRequest = (imodel: IModelDb, keys: KeySet): KeySet => {\n const elementClassName = \"BisCore:Element\";\n const instanceKeys = keys.instanceKeys;\n if (!instanceKeys.has(elementClassName))\n return keys;\n\n const elementIds = instanceKeys.get(elementClassName)!;\n const keyset = new KeySet();\n keyset.add(keys);\n elementIds.forEach((elementId) => {\n const concreteKey = getElementKey(imodel, elementId);\n if (concreteKey) {\n keyset.delete({ className: elementClassName, id: elementId });\n keyset.add(concreteKey);\n }\n });\n return keyset;\n};\n\nconst createContentDescriptorOverrides = (descriptorOrOverrides: Descriptor | DescriptorOverrides): DescriptorOverrides => {\n if (descriptorOrOverrides instanceof Descriptor)\n return descriptorOrOverrides.createDescriptorOverrides();\n return descriptorOrOverrides;\n};\n\nconst createLocaleDirectoryList = (props?: PresentationManagerProps) => {\n const localeDirectories = [getLocalesDirectory(getPresentationCommonAssetsRoot(props?.presentationAssetsRoot))];\n if (props && props.localeDirectories) {\n props.localeDirectories.forEach((dir) => {\n if (-1 === localeDirectories.indexOf(dir))\n localeDirectories.push(dir);\n });\n }\n return localeDirectories;\n};\n\nconst createTaskAllocationsMap = (props?: PresentationManagerProps) => {\n const count = props?.workerThreadsCount ?? 2;\n return {\n [Number.MAX_SAFE_INTEGER]: count,\n };\n};\n\nconst normalizeLocale = (locale?: string) => {\n if (!locale)\n return undefined;\n return locale.toLocaleLowerCase();\n};\n\nconst normalizeDirectory = (directory?: string) => {\n return directory ? path.resolve(directory) : \"\";\n};\n\nconst toNativeUnitSystem = (unitSystem: UnitSystemKey) => {\n switch (unitSystem) {\n case \"imperial\": return NativePresentationUnitSystem.BritishImperial;\n case \"metric\": return NativePresentationUnitSystem.Metric;\n case \"usCustomary\": return NativePresentationUnitSystem.UsCustomary;\n case \"usSurvey\": return NativePresentationUnitSystem.UsSurvey;\n }\n};\n\nconst toOptionalNativeUnitSystem = (unitSystem: UnitSystemKey | undefined) => {\n return unitSystem ? toNativeUnitSystem(unitSystem) : undefined;\n};\n\nconst toNativeUnitFormatsMap = (map: { [phenomenon: string]: UnitSystemFormat } | undefined) => {\n if (!map)\n return undefined;\n\n const nativeFormatsMap: NativePresentationDefaultUnitFormats = {};\n Object.keys(map).forEach((phenomenon) => {\n const unitSystemsFormat = map[phenomenon];\n nativeFormatsMap[phenomenon] = {\n unitSystems: unitSystemsFormat.unitSystems.map(toNativeUnitSystem),\n format: unitSystemsFormat.format,\n };\n });\n return nativeFormatsMap;\n};\n\nconst createCacheConfig = (config?: HierarchyCacheConfig): IModelJsNative.ECPresentationHierarchyCacheConfig => {\n if (config?.mode === HierarchyCacheMode.Disk)\n return { ...config, directory: normalizeDirectory(config.directory) };\n if (config?.mode === HierarchyCacheMode.Hybrid)\n return { ...config, disk: config.disk ? { ...config.disk, directory: normalizeDirectory(config.disk.directory) } : undefined };\n if (config?.mode === HierarchyCacheMode.Memory)\n return config;\n return { mode: HierarchyCacheMode.Disk, directory: \"\" };\n};\n\nconst getPresentationBackendAssetsRoot = (ovr?: string | { backend: string }) => {\n if (typeof ovr === \"string\")\n return ovr;\n if (typeof ovr === \"object\")\n return ovr.backend;\n return PRESENTATION_BACKEND_ASSETS_ROOT;\n};\n\nconst getPresentationCommonAssetsRoot = (ovr?: string | { common: string }) => {\n if (typeof ovr === \"string\")\n return ovr;\n if (typeof ovr === \"object\")\n return ovr.common;\n return PRESENTATION_COMMON_ASSETS_ROOT;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-backend",
|
|
3
|
-
"version": "3.0.0-dev.
|
|
3
|
+
"version": "3.0.0-dev.73",
|
|
4
4
|
"description": "Backend of iModel.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
"main": "lib/presentation-backend.js",
|
|
22
22
|
"typings": "lib/presentation-backend",
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@itwin/core-bentley": "^3.0.0-dev.
|
|
25
|
-
"@itwin/core-backend": "^3.0.0-dev.
|
|
26
|
-
"@itwin/core-common": "^3.0.0-dev.
|
|
27
|
-
"@itwin/core-quantity": "^3.0.0-dev.
|
|
28
|
-
"@itwin/presentation-common": "^3.0.0-dev.
|
|
24
|
+
"@itwin/core-bentley": "^3.0.0-dev.73",
|
|
25
|
+
"@itwin/core-backend": "^3.0.0-dev.73",
|
|
26
|
+
"@itwin/core-common": "^3.0.0-dev.73",
|
|
27
|
+
"@itwin/core-quantity": "^3.0.0-dev.73",
|
|
28
|
+
"@itwin/presentation-common": "^3.0.0-dev.73"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@itwin/core-bentley": "3.0.0-dev.
|
|
32
|
-
"@itwin/build-tools": "3.0.0-dev.
|
|
33
|
-
"@itwin/eslint-plugin": "3.0.0-dev.
|
|
34
|
-
"@itwin/core-backend": "3.0.0-dev.
|
|
35
|
-
"@itwin/core-common": "3.0.0-dev.
|
|
36
|
-
"@itwin/core-quantity": "3.0.0-dev.
|
|
37
|
-
"@itwin/presentation-common": "3.0.0-dev.
|
|
31
|
+
"@itwin/core-bentley": "3.0.0-dev.73",
|
|
32
|
+
"@itwin/build-tools": "3.0.0-dev.73",
|
|
33
|
+
"@itwin/eslint-plugin": "3.0.0-dev.73",
|
|
34
|
+
"@itwin/core-backend": "3.0.0-dev.73",
|
|
35
|
+
"@itwin/core-common": "3.0.0-dev.73",
|
|
36
|
+
"@itwin/core-quantity": "3.0.0-dev.73",
|
|
37
|
+
"@itwin/presentation-common": "3.0.0-dev.73",
|
|
38
38
|
"@types/chai": "^4.1.4",
|
|
39
39
|
"@types/chai-as-promised": "^7",
|
|
40
40
|
"@types/chai-jest-snapshot": "^1.3.0",
|
|
@@ -85,19 +85,19 @@
|
|
|
85
85
|
"extends": "plugin:@itwin/itwinjs-recommended"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"compile": "npm run build",
|
|
89
|
-
"build": "tsc 1>&2 && npm run build:assets",
|
|
88
|
+
"compile": "npm run -s build",
|
|
89
|
+
"build": "tsc 1>&2 && npm run -s build:assets",
|
|
90
90
|
"build:assets": "cpx \"./assets/**/*\" ./lib/assets",
|
|
91
|
-
"build:watch": "npm run build:assets && tsc -w",
|
|
91
|
+
"build:watch": "npm run -s build:assets && tsc -w",
|
|
92
92
|
"clean": "rimraf lib .rush/temp/package-deps*.json",
|
|
93
|
-
"cover": "nyc npm test",
|
|
94
|
-
"docs": "npm run docs:reference && npm run extract && npm run docs:changelog",
|
|
93
|
+
"cover": "nyc npm -s test",
|
|
94
|
+
"docs": "npm run -s docs:reference && npm run -s extract && npm run -s docs:changelog",
|
|
95
95
|
"docs:changelog": "cpx ./CHANGELOG.md ../../generated-docs/presentation/presentation-backend",
|
|
96
96
|
"docs:reference": "betools docs --includes=../../generated-docs/extract --json=../../generated-docs/presentation/presentation-backend/file.json --tsIndexFile=presentation-backend.ts --onlyJson",
|
|
97
97
|
"extract": "betools extract --fileExt=ts --extractFrom=./src/test --recursive --out=../../generated-docs/extract",
|
|
98
98
|
"extract-api": "betools extract-api --entry=presentation-backend",
|
|
99
99
|
"lint": "eslint -f visualstudio \"./src/**/*.ts\" 1>&2",
|
|
100
100
|
"test": "mocha --config ../.mocharc.json --file ./lib/test/index.test.js \"./lib/test/**/*.test.js\"",
|
|
101
|
-
"test:watch": "npm test -- --reporter min --watch-extensions ts --watch"
|
|
101
|
+
"test:watch": "npm -s test -- --reporter min --watch-extensions ts --watch"
|
|
102
102
|
}
|
|
103
103
|
}
|