@itwin/presentation-backend 5.0.0-dev.6 → 5.0.0-dev.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -1
- package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +31 -4
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +161 -57
- package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +2 -2
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +3 -1
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +19 -15
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js +1 -4
- package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +2 -0
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +51 -77
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +3 -3
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +20 -20
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +8 -8
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +36 -63
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetEmbedder.js +8 -6
- package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetManager.js +2 -1
- package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js +2 -0
- package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js +22 -25
- package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +2 -3
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js +30 -26
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/Utils.js +1 -2
- package/lib/cjs/presentation-backend/Utils.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
- package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
- package/lib/cjs/presentation-backend.js.map +1 -1
- package/package.json +18 -17
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
/** @packageDocumentation
|
|
7
7
|
* @module Core
|
|
8
8
|
*/
|
|
9
|
-
var _a;
|
|
10
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
10
|
exports.Presentation = void 0;
|
|
12
11
|
const core_backend_1 = require("@itwin/core-backend");
|
|
@@ -29,6 +28,12 @@ const TemporaryStorage_1 = require("./TemporaryStorage");
|
|
|
29
28
|
* @public
|
|
30
29
|
*/
|
|
31
30
|
class Presentation {
|
|
31
|
+
static _initProps;
|
|
32
|
+
static _clientsStorage;
|
|
33
|
+
static _disposeIpcHandler;
|
|
34
|
+
static _shutdownListener;
|
|
35
|
+
static _disposeIModelOpenedListener;
|
|
36
|
+
static _rpcImpl;
|
|
32
37
|
/* istanbul ignore next */
|
|
33
38
|
constructor() { }
|
|
34
39
|
/** Properties used to initialize the presentation framework */
|
|
@@ -46,7 +51,7 @@ class Presentation {
|
|
|
46
51
|
*/
|
|
47
52
|
static initialize(props) {
|
|
48
53
|
this._initProps = props || {};
|
|
49
|
-
this._shutdownListener = core_backend_1.IModelHost.onBeforeShutdown.addListener(() =>
|
|
54
|
+
this._shutdownListener = core_backend_1.IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());
|
|
50
55
|
this._rpcImpl = new PresentationRpcImpl_1.PresentationRpcImpl({
|
|
51
56
|
requestTimeout: this._initProps.requestTimeout,
|
|
52
57
|
});
|
|
@@ -76,7 +81,7 @@ class Presentation {
|
|
|
76
81
|
*/
|
|
77
82
|
static terminate() {
|
|
78
83
|
if (this._clientsStorage) {
|
|
79
|
-
this._clientsStorage.dispose();
|
|
84
|
+
this._clientsStorage[Symbol.dispose]();
|
|
80
85
|
this._clientsStorage = undefined;
|
|
81
86
|
}
|
|
82
87
|
if (this._disposeIModelOpenedListener) {
|
|
@@ -89,7 +94,7 @@ class Presentation {
|
|
|
89
94
|
}
|
|
90
95
|
core_common_1.RpcManager.unregisterImpl(presentation_common_1.PresentationRpcInterface);
|
|
91
96
|
if (this._rpcImpl) {
|
|
92
|
-
this._rpcImpl.dispose();
|
|
97
|
+
this._rpcImpl[Symbol.dispose]();
|
|
93
98
|
this._rpcImpl = undefined;
|
|
94
99
|
}
|
|
95
100
|
if (this._disposeIpcHandler) {
|
|
@@ -98,15 +103,15 @@ class Presentation {
|
|
|
98
103
|
this._initProps = undefined;
|
|
99
104
|
}
|
|
100
105
|
static createClientManager(clientId, onManagerUsed) {
|
|
101
|
-
const manager =
|
|
102
|
-
?
|
|
103
|
-
: new PresentationManager_1.PresentationManager({ ...
|
|
106
|
+
const manager = Presentation._initProps && Presentation._initProps.clientManagerFactory
|
|
107
|
+
? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)
|
|
108
|
+
: new PresentationManager_1.PresentationManager({ ...Presentation._initProps, id: clientId });
|
|
104
109
|
manager.setOnManagerUsedHandler(onManagerUsed);
|
|
105
110
|
core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage.values.length}.`);
|
|
106
111
|
return { manager };
|
|
107
112
|
}
|
|
108
113
|
static disposeClientManager(_id, storeItem) {
|
|
109
|
-
storeItem.manager.dispose();
|
|
114
|
+
storeItem.manager[Symbol.dispose]();
|
|
110
115
|
}
|
|
111
116
|
/**
|
|
112
117
|
* Get an instance of [[PresentationManager]] for specific client
|
|
@@ -128,13 +133,12 @@ class Presentation {
|
|
|
128
133
|
}
|
|
129
134
|
return this._rpcImpl.requestTimeout;
|
|
130
135
|
}
|
|
136
|
+
static onIModelOpened = (imodel) => {
|
|
137
|
+
const manager = this.getManager();
|
|
138
|
+
const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
140
|
+
manager.getNativePlatform().forceLoadSchemas(imodelAddon);
|
|
141
|
+
};
|
|
131
142
|
}
|
|
132
143
|
exports.Presentation = Presentation;
|
|
133
|
-
_a = Presentation;
|
|
134
|
-
Presentation.onIModelOpened = (imodel) => {
|
|
135
|
-
const manager = _a.getManager();
|
|
136
|
-
const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);
|
|
137
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
138
|
-
manager.getNativePlatform().forceLoadSchemas(imodelAddon);
|
|
139
|
-
};
|
|
140
144
|
//# sourceMappingURL=Presentation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;AAEH,sDAA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AAQ,KAAK,SAAS,EAAE,CAAC;YAChC,MAAM,IAAI,uCAAiB,CAAC,wCAAkB,CAAC,cAAc,EAAE,2EAA2E,CAAC,CAAC;QAC9I,CAAC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;IACtC,CAAC;;AA9HH,oCAsIC;;AANgB,2BAAc,GAAG,CAAC,MAAmB,EAAE,EAAE;IACtD,MAAM,OAAO,GAAG,EAAI,CAAC,UAAU,EAAE,CAAC;IAClC,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACvE,mEAAmE;IACnE,OAAO,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;AAC5D,CAAC,AAL4B,CAK3B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\r\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\r\nimport { RpcManager } from \"@itwin/core-common\";\r\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\r\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler\";\r\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\r\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl\";\r\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage\";\r\n\r\n/**\r\n * Properties that can be used to configure [[Presentation]] API.\r\n * @public\r\n */\r\nexport interface PresentationProps extends Omit<PresentationManagerProps, \"enableSchemasPreload\"> {\r\n /**\r\n * Time in milliseconds after which the request will timeout.\r\n */\r\n requestTimeout?: number;\r\n\r\n /**\r\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\r\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\r\n */\r\n enableSchemasPreload?: boolean;\r\n\r\n /**\r\n * Factory method for creating separate managers for each client\r\n * @internal\r\n */\r\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\r\n\r\n /**\r\n * How much time should an unused client manager be stored in memory\r\n * before it's disposed.\r\n */\r\n unusedClientLifetime?: number;\r\n}\r\n\r\n/**\r\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\r\n * instances, one for each frontend.\r\n *\r\n * @public\r\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\r\n */\r\nexport type MultiManagerPresentationProps = PresentationProps;\r\n\r\n/**\r\n * Base props for initializing the [[Presentation]] library.\r\n *\r\n * @public\r\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\r\n */\r\nexport type PresentationPropsBase = PresentationProps;\r\n\r\n/**\r\n * Props for initializing the [[Presentation]] library with ability to use a single\r\n * [[PresentationManager]] instance for handling all requests.\r\n *\r\n * @public\r\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\r\n */\r\nexport type SingleManagerPresentationProps = Omit<PresentationProps, \"clientManagerFactory\" | \"unusedClientLifetime\">;\r\n\r\ninterface ClientStoreItem {\r\n manager: PresentationManager;\r\n}\r\n\r\n/**\r\n * Static class used to statically set up Presentation library for the backend.\r\n * Basically what it does is:\r\n * - Register a RPC implementation\r\n * - Create a singleton [[PresentationManager]] instance\r\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\r\n * the presentation manager when that happens.\r\n *\r\n * @public\r\n */\r\nexport class Presentation {\r\n private static _initProps: PresentationProps | undefined;\r\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\r\n private static _disposeIpcHandler: DisposeFunc | undefined;\r\n private static _shutdownListener: DisposeFunc | undefined;\r\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\r\n private static _rpcImpl: PresentationRpcImpl | undefined;\r\n\r\n /* istanbul ignore next */\r\n private constructor() {}\r\n\r\n /** Properties used to initialize the presentation framework */\r\n public static get initProps() {\r\n return this._initProps;\r\n }\r\n\r\n /**\r\n * Initializes Presentation library for the backend.\r\n *\r\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\r\n *\r\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\r\n *\r\n * @param props Optional properties for [[PresentationManager]]\r\n */\r\n public static initialize(props?: PresentationProps): void {\r\n this._initProps = props || {};\r\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\r\n\r\n this._rpcImpl = new PresentationRpcImpl({\r\n requestTimeout: this._initProps.requestTimeout,\r\n });\r\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\r\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\r\n\r\n if (IpcHost.isValid) {\r\n this._disposeIpcHandler = PresentationIpcHandler.register();\r\n }\r\n\r\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\r\n factory: this.createClientManager.bind(this),\r\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\r\n // cleanup unused managers every minute\r\n cleanupInterval: 60 * 1000,\r\n // by default, manager is disposed after 1 hour of being unused\r\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\r\n // add some logging\r\n onDisposedSingle: /* istanbul ignore next */ (id: string) =>\r\n Logger.logInfo(\r\n PresentationBackendLoggerCategory.PresentationManager,\r\n `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`,\r\n ),\r\n onDisposedAll: /* istanbul ignore next */ () =>\r\n Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\r\n });\r\n\r\n if (this._initProps.enableSchemasPreload) {\r\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\r\n }\r\n }\r\n\r\n /**\r\n * Terminates Presentation. Consumers don't need to call this as it's automatically\r\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\r\n */\r\n public static terminate(): void {\r\n if (this._clientsStorage) {\r\n this._clientsStorage.dispose();\r\n this._clientsStorage = undefined;\r\n }\r\n if (this._disposeIModelOpenedListener) {\r\n this._disposeIModelOpenedListener();\r\n this._disposeIModelOpenedListener = undefined;\r\n }\r\n if (this._shutdownListener) {\r\n this._shutdownListener();\r\n this._shutdownListener = undefined;\r\n }\r\n RpcManager.unregisterImpl(PresentationRpcInterface);\r\n if (this._rpcImpl) {\r\n this._rpcImpl.dispose();\r\n this._rpcImpl = undefined;\r\n }\r\n if (this._disposeIpcHandler) {\r\n this._disposeIpcHandler();\r\n }\r\n this._initProps = undefined;\r\n }\r\n\r\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\r\n const manager =\r\n Presentation._initProps && Presentation._initProps.clientManagerFactory\r\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\r\n : new PresentationManager({ ...Presentation._initProps, id: clientId });\r\n manager.setOnManagerUsedHandler(onManagerUsed);\r\n Logger.logInfo(\r\n PresentationBackendLoggerCategory.PresentationManager,\r\n `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`,\r\n );\r\n return { manager };\r\n }\r\n\r\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\r\n storeItem.manager.dispose();\r\n }\r\n\r\n /**\r\n * Get an instance of [[PresentationManager]] for specific client\r\n * @param clientId ID of the client requesting presentation data. If no\r\n * ID is provided, the default [[PresentationManager]] is returned.\r\n */\r\n public static getManager(clientId?: string): PresentationManager {\r\n if (this._clientsStorage) {\r\n return this._clientsStorage.getValue(clientId || \"\").manager;\r\n }\r\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\r\n }\r\n\r\n /**\r\n * Get the time in milliseconds that backend should respond in .\r\n */\r\n public static getRequestTimeout(): number {\r\n if (this._rpcImpl === undefined) {\r\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\r\n }\r\n return this._rpcImpl.requestTimeout;\r\n }\r\n\r\n private static onIModelOpened = (imodel: BriefcaseDb) => {\r\n const manager = this.getManager();\r\n const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n manager.getNativePlatform().forceLoadSchemas(imodelAddon);\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAuE;AACvE,sDAA0D;AAC1D,oDAAgD;AAChD,oEAA6G;AAC7G,mEAA4E;AAC5E,qEAAkE;AAClE,+DAAsF;AACtF,+DAA4D;AAC5D,yDAAkE;AA6DlE;;;;;;;;;GASG;AACH,MAAa,YAAY;IACf,MAAM,CAAC,UAAU,CAAgC;IACjD,MAAM,CAAC,eAAe,CAA4D;IAClF,MAAM,CAAC,kBAAkB,CAA0B;IACnD,MAAM,CAAC,iBAAiB,CAA0B;IAClD,MAAM,CAAC,4BAA4B,CAA0B;IAC7D,MAAM,CAAC,QAAQ,CAAkC;IAEzD,0BAA0B;IAC1B,gBAAuB,CAAC;IAExB,+DAA+D;IACxD,MAAM,KAAK,SAAS;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,UAAU,CAAC,KAAyB;QAChD,IAAI,CAAC,UAAU,GAAG,KAAK,IAAI,EAAE,CAAC;QAC9B,IAAI,CAAC,iBAAiB,GAAG,yBAAU,CAAC,gBAAgB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,CAAC,CAAC;QAEjG,IA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;;AArIJ,oCAsIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Core\n */\n\nimport { BriefcaseDb, IModelHost, IpcHost } from \"@itwin/core-backend\";\nimport { DisposeFunc, Logger } from \"@itwin/core-bentley\";\nimport { RpcManager } from \"@itwin/core-common\";\nimport { PresentationError, PresentationRpcInterface, PresentationStatus } from \"@itwin/presentation-common\";\nimport { PresentationBackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler\";\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager\";\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl\";\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage\";\n\n/**\n * Properties that can be used to configure [[Presentation]] API.\n * @public\n */\nexport interface PresentationProps extends Omit<PresentationManagerProps, \"enableSchemasPreload\"> {\n /**\n * Time in milliseconds after which the request will timeout.\n */\n requestTimeout?: number;\n\n /**\n * Should schemas preloading be enabled. If true, [[Presentation]] library listens\n * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.\n */\n enableSchemasPreload?: boolean;\n\n /**\n * Factory method for creating separate managers for each client\n * @internal\n */\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\n\n /**\n * How much time should an unused client manager be stored in memory\n * before it's disposed.\n */\n unusedClientLifetime?: number;\n}\n\n/**\n * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]\n * instances, one for each frontend.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type MultiManagerPresentationProps = PresentationProps;\n\n/**\n * Base props for initializing the [[Presentation]] library.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type PresentationPropsBase = PresentationProps;\n\n/**\n * Props for initializing the [[Presentation]] library with ability to use a single\n * [[PresentationManager]] instance for handling all requests.\n *\n * @public\n * @deprecated in 4.8 - use [[PresentationProps]] instead.\n */\nexport type SingleManagerPresentationProps = Omit<PresentationProps, \"clientManagerFactory\" | \"unusedClientLifetime\">;\n\ninterface ClientStoreItem {\n manager: PresentationManager;\n}\n\n/**\n * Static class used to statically set up Presentation library for the backend.\n * Basically what it does is:\n * - Register a RPC implementation\n * - Create a singleton [[PresentationManager]] instance\n * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate\n * the presentation manager when that happens.\n *\n * @public\n */\nexport class Presentation {\n private static _initProps: PresentationProps | undefined;\n private static _clientsStorage: FactoryBasedTemporaryStorage<ClientStoreItem> | undefined;\n private static _disposeIpcHandler: DisposeFunc | undefined;\n private static _shutdownListener: DisposeFunc | undefined;\n private static _disposeIModelOpenedListener: DisposeFunc | undefined;\n private static _rpcImpl: PresentationRpcImpl | undefined;\n\n /* istanbul ignore next */\n private constructor() {}\n\n /** Properties used to initialize the presentation framework */\n public static get initProps() {\n return this._initProps;\n }\n\n /**\n * Initializes Presentation library for the backend.\n *\n * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.\n *\n * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)\n *\n * @param props Optional properties for [[PresentationManager]]\n */\n public static initialize(props?: PresentationProps): void {\n this._initProps = props || {};\n this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());\n\n this._rpcImpl = new PresentationRpcImpl({\n requestTimeout: this._initProps.requestTimeout,\n });\n RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);\n RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);\n\n if (IpcHost.isValid) {\n this._disposeIpcHandler = PresentationIpcHandler.register();\n }\n\n this._clientsStorage = new FactoryBasedTemporaryStorage<ClientStoreItem>({\n factory: this.createClientManager.bind(this),\n cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),\n // cleanup unused managers every minute\n cleanupInterval: 60 * 1000,\n // by default, manager is disposed after 1 hour of being unused\n unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,\n // add some logging\n onDisposedSingle: /* istanbul ignore next */ (id: string) =>\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage!.values.length}.`,\n ),\n onDisposedAll: /* istanbul ignore next */ () =>\n Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),\n });\n\n if (this._initProps.enableSchemasPreload) {\n this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);\n }\n }\n\n /**\n * Terminates Presentation. Consumers don't need to call this as it's automatically\n * called on [IModelHost.onBeforeShutdown]($core-backend) event.\n */\n public static terminate(): void {\n if (this._clientsStorage) {\n this._clientsStorage[Symbol.dispose]();\n this._clientsStorage = undefined;\n }\n if (this._disposeIModelOpenedListener) {\n this._disposeIModelOpenedListener();\n this._disposeIModelOpenedListener = undefined;\n }\n if (this._shutdownListener) {\n this._shutdownListener();\n this._shutdownListener = undefined;\n }\n RpcManager.unregisterImpl(PresentationRpcInterface);\n if (this._rpcImpl) {\n this._rpcImpl[Symbol.dispose]();\n this._rpcImpl = undefined;\n }\n if (this._disposeIpcHandler) {\n this._disposeIpcHandler();\n }\n this._initProps = undefined;\n }\n\n private static createClientManager(clientId: string, onManagerUsed: () => void): ClientStoreItem {\n const manager =\n Presentation._initProps && Presentation._initProps.clientManagerFactory\n ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)\n : new PresentationManager({ ...Presentation._initProps, id: clientId });\n manager.setOnManagerUsedHandler(onManagerUsed);\n Logger.logInfo(\n PresentationBackendLoggerCategory.PresentationManager,\n `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage!.values.length}.`,\n );\n return { manager };\n }\n\n private static disposeClientManager(_id: string, storeItem: ClientStoreItem) {\n storeItem.manager[Symbol.dispose]();\n }\n\n /**\n * Get an instance of [[PresentationManager]] for specific client\n * @param clientId ID of the client requesting presentation data. If no\n * ID is provided, the default [[PresentationManager]] is returned.\n */\n public static getManager(clientId?: string): PresentationManager {\n if (this._clientsStorage) {\n return this._clientsStorage.getValue(clientId || \"\").manager;\n }\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n\n /**\n * Get the time in milliseconds that backend should respond in .\n */\n public static getRequestTimeout(): number {\n if (this._rpcImpl === undefined) {\n throw new PresentationError(PresentationStatus.NotInitialized, \"Presentation must be first initialized by calling Presentation.initialize\");\n }\n return this._rpcImpl.requestTimeout;\n }\n\n private static onIModelOpened = (imodel: BriefcaseDb) => {\n const manager = this.getManager();\n const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n manager.getNativePlatform().forceLoadSchemas(imodelAddon);\n };\n}\n"]}
|
|
@@ -13,10 +13,7 @@ const presentation_common_1 = require("@itwin/presentation-common");
|
|
|
13
13
|
const Presentation_1 = require("./Presentation");
|
|
14
14
|
/** @internal */
|
|
15
15
|
class PresentationIpcHandler extends core_backend_1.IpcHandler {
|
|
16
|
-
|
|
17
|
-
super(...arguments);
|
|
18
|
-
this.channelName = presentation_common_1.PRESENTATION_IPC_CHANNEL_NAME;
|
|
19
|
-
}
|
|
16
|
+
channelName = presentation_common_1.PRESENTATION_IPC_CHANNEL_NAME;
|
|
20
17
|
async setRulesetVariable(params) {
|
|
21
18
|
const { clientId, rulesetId, variable } = params;
|
|
22
19
|
const parsedVariable = presentation_common_1.RulesetVariable.fromJSON(variable);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationIpcHandler.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAiD;AACjD,oEAOoC;AACpC,iDAA8C;AAE9C,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,yBAAU;
|
|
1
|
+
{"version":3,"file":"PresentationIpcHandler.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAAiD;AACjD,oEAOoC;AACpC,iDAA8C;AAE9C,gBAAgB;AAChB,MAAa,sBAAuB,SAAQ,yBAAU;IAC7C,WAAW,GAAG,mDAA6B,CAAC;IAE5C,KAAK,CAAC,kBAAkB,CAAC,MAAqD;QACnF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QACjD,MAAM,cAAc,GAAG,qCAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1D,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,EAAE,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3H,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,MAAkC;QAClE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QACnD,2BAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;CACF;AAbD,wDAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module RPC\n */\n\nimport { IpcHandler } from \"@itwin/core-backend\";\nimport {\n PRESENTATION_IPC_CHANNEL_NAME,\n PresentationIpcInterface,\n RulesetVariable,\n RulesetVariableJSON,\n SetRulesetVariableParams,\n UnsetRulesetVariableParams,\n} from \"@itwin/presentation-common\";\nimport { Presentation } from \"./Presentation\";\n\n/** @internal */\nexport class PresentationIpcHandler extends IpcHandler implements PresentationIpcInterface {\n public channelName = PRESENTATION_IPC_CHANNEL_NAME;\n\n public async setRulesetVariable(params: SetRulesetVariableParams<RulesetVariableJSON>): Promise<void> {\n const { clientId, rulesetId, variable } = params;\n const parsedVariable = RulesetVariable.fromJSON(variable);\n Presentation.getManager(clientId).vars(rulesetId).setValue(parsedVariable.id, parsedVariable.type, parsedVariable.value);\n }\n\n public async unsetRulesetVariable(params: UnsetRulesetVariableParams): Promise<void> {\n const { clientId, rulesetId, variableId } = params;\n Presentation.getManager(clientId).vars(rulesetId).unset(variableId);\n }\n}\n"]}
|
|
@@ -335,6 +335,8 @@ export declare class PresentationManager {
|
|
|
335
335
|
get activeUnitSystem(): UnitSystemKey | undefined;
|
|
336
336
|
set activeUnitSystem(value: UnitSystemKey | undefined);
|
|
337
337
|
/** Dispose the presentation manager. Must be called to clean up native resources. */
|
|
338
|
+
[Symbol.dispose](): void;
|
|
339
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
338
340
|
dispose(): void;
|
|
339
341
|
/** @internal */
|
|
340
342
|
setOnManagerUsedHandler(handler: () => void): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"PresentationManager.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAa,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAA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AAe,EAAE,CAAC;IAK7B;;;OAGG;IACU,kBAAkB,CAAC,eAAe,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAAG,2BAA2B,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIjJ;;;;OAIG;IACU,gBAAgB,CAC3B,cAAc,EAAE,4BAA4B,CAAC,QAAQ,CAAC,GAAG;QAAE,GAAG,EAAE,UAAU,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,2BAA2B,GAC5H,OAAO,CAAC,MAAM,CAAC;IAClB;;;OAGG;IAEU,gBAAgB,CAAC,cAAc,EAAE,8BAA8B,CAAC,QAAQ,CAAC,GAAG,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAetI;;;OAGG;IACU,kBAAkB,CAAC,cAAc,EAAE,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;CA4B3H"}
|
|
@@ -65,15 +65,19 @@ var HierarchyCacheMode;
|
|
|
65
65
|
* @public
|
|
66
66
|
*/
|
|
67
67
|
class PresentationManager {
|
|
68
|
+
_props;
|
|
69
|
+
_detail;
|
|
70
|
+
_localizationHelper;
|
|
71
|
+
/**
|
|
72
|
+
* Get / set active locale used for localizing presentation data
|
|
73
|
+
* @deprecated in 3.x. Use [[PresentationManagerProps.getLocalizedString]] to localize data returned by [[PresentationManager]].
|
|
74
|
+
*/
|
|
75
|
+
activeLocale;
|
|
68
76
|
/**
|
|
69
77
|
* Creates an instance of PresentationManager.
|
|
70
78
|
* @param props Optional configuration properties.
|
|
71
79
|
*/
|
|
72
80
|
constructor(props) {
|
|
73
|
-
/** @internal */
|
|
74
|
-
this.getNativePlatform = () => {
|
|
75
|
-
return this._detail.getNativePlatform();
|
|
76
|
-
};
|
|
77
81
|
this._props = props ?? {};
|
|
78
82
|
this._detail = new PresentationManagerDetail_1.PresentationManagerDetail(this._props);
|
|
79
83
|
this.activeLocale = this._props.defaultLocale; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
@@ -88,8 +92,13 @@ class PresentationManager {
|
|
|
88
92
|
this._detail.activeUnitSystem = value;
|
|
89
93
|
}
|
|
90
94
|
/** Dispose the presentation manager. Must be called to clean up native resources. */
|
|
95
|
+
[Symbol.dispose]() {
|
|
96
|
+
this._detail[Symbol.dispose]();
|
|
97
|
+
}
|
|
98
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
99
|
+
// istanbul ignore next
|
|
91
100
|
dispose() {
|
|
92
|
-
this.
|
|
101
|
+
this[Symbol.dispose]();
|
|
93
102
|
}
|
|
94
103
|
/** @internal */
|
|
95
104
|
setOnManagerUsedHandler(handler) {
|
|
@@ -111,6 +120,10 @@ class PresentationManager {
|
|
|
111
120
|
return new RulesetVariablesManager_1.RulesetVariablesManagerImpl(this.getNativePlatform, rulesetId);
|
|
112
121
|
}
|
|
113
122
|
/** @internal */
|
|
123
|
+
getNativePlatform = () => {
|
|
124
|
+
return this._detail.getNativePlatform();
|
|
125
|
+
};
|
|
126
|
+
/** @internal */
|
|
114
127
|
// istanbul ignore next
|
|
115
128
|
getDetail() {
|
|
116
129
|
return this._detail;
|
|
@@ -124,11 +137,9 @@ class PresentationManager {
|
|
|
124
137
|
* @public
|
|
125
138
|
*/
|
|
126
139
|
async getNodes(requestOptions) {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const nodes = presentation_common_1.Node.listFromJSON(nodesJson.nodes);
|
|
131
|
-
return this._localizationHelper.getLocalizedNodes(nodes);
|
|
140
|
+
const serializedHierarchyLevel = await this._detail.getNodes(requestOptions);
|
|
141
|
+
const hierarchyLevel = (0, presentation_common_1.deepReplaceNullsToUndefined)(JSON.parse(serializedHierarchyLevel));
|
|
142
|
+
return this._localizationHelper.getLocalizedNodes(hierarchyLevel.nodes);
|
|
132
143
|
}
|
|
133
144
|
/**
|
|
134
145
|
* Retrieves nodes count
|
|
@@ -260,7 +271,7 @@ class PresentationManager {
|
|
|
260
271
|
return parser(content.descriptor, content.contentSet[0]);
|
|
261
272
|
}
|
|
262
273
|
async getMultipleElementProperties(requestOptions) {
|
|
263
|
-
const {
|
|
274
|
+
const { contentParser, batchSize: batchSizeOption, ...contentOptions } = requestOptions;
|
|
264
275
|
const parser = contentParser ?? presentation_common_1.buildElementProperties;
|
|
265
276
|
const workerThreadsCount = this._props.workerThreadsCount ?? 2;
|
|
266
277
|
// We don't want to request content for all classes at once - each class results in a huge content descriptor object that's cached in memory
|
|
@@ -268,75 +279,40 @@ class PresentationManager {
|
|
|
268
279
|
// but also may push descriptors out of cache, requiring us to recreate them, thus making performance worse. For those reasons we handle at
|
|
269
280
|
// most `workerThreadsCount / 2` classes in parallel.
|
|
270
281
|
// istanbul ignore next
|
|
271
|
-
const classParallelism = workerThreadsCount > 1 ? workerThreadsCount / 2 : 1;
|
|
282
|
+
const classParallelism = workerThreadsCount > 1 ? Math.ceil(workerThreadsCount / 2) : 1;
|
|
272
283
|
// We want all worker threads to be constantly busy. However, there's some fairly expensive work being done after the worker thread is done,
|
|
273
284
|
// but before we receive the response. That means the worker thread would be starving if we sent only `workerThreadsCount` requests in parallel.
|
|
274
285
|
// To avoid that, we keep twice as much requests active.
|
|
275
286
|
// istanbul ignore next
|
|
276
|
-
const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
const getContentDescriptor = async (ruleset) => {
|
|
300
|
-
return (await this.getContentDescriptor({
|
|
301
|
-
...contentOptions,
|
|
302
|
-
rulesetOrId: ruleset,
|
|
303
|
-
displayType: presentation_common_1.DefaultContentDisplayTypes.Grid,
|
|
304
|
-
contentFlags: presentation_common_1.ContentFlags.ShowLabels,
|
|
305
|
-
keys: new presentation_common_1.KeySet(),
|
|
306
|
-
}));
|
|
307
|
-
};
|
|
308
|
-
const obs = (0, ElementPropertiesHelper_1.getClassesWithInstances)(requestOptions.imodel, elementClasses ?? /* istanbul ignore next */ ["BisCore.Element"]).pipe((0, rxjs_1.map)((classFullName) => ({
|
|
309
|
-
classFullName,
|
|
310
|
-
ruleset: createClassContentRuleset(classFullName),
|
|
311
|
-
})), (0, rxjs_1.mergeMap)(({ classFullName, ruleset }) =>
|
|
312
|
-
// use forkJoin to query descriptor and element ids in parallel
|
|
313
|
-
(0, rxjs_1.forkJoin)({
|
|
314
|
-
classFullName: (0, rxjs_1.of)(classFullName),
|
|
315
|
-
ruleset: (0, rxjs_1.of)(ruleset),
|
|
316
|
-
descriptor: (0, rxjs_1.from)(getContentDescriptor(ruleset)),
|
|
317
|
-
batches: (0, rxjs_1.from)((0, ElementPropertiesHelper_1.getBatchedClassElementIds)(requestOptions.imodel, classFullName, batchSize ?? /* istanbul ignore next */ 1000)),
|
|
318
|
-
}).pipe(
|
|
319
|
-
// split incoming stream into individual batch requests
|
|
320
|
-
(0, rxjs_1.mergeMap)(({ descriptor, batches }) => (0, rxjs_1.from)(batches.map((batch) => ({ classFullName, descriptor, batch })))),
|
|
321
|
-
// request content for each batch, filter by IDs for performance
|
|
322
|
-
(0, rxjs_1.mergeMap)(({ descriptor, batch }) => {
|
|
323
|
-
const filteringDescriptor = new presentation_common_1.Descriptor(descriptor);
|
|
324
|
-
filteringDescriptor.instanceFilter = {
|
|
325
|
-
selectClassName: classFullName,
|
|
326
|
-
expression: `this.ECInstanceId >= ${Number.parseInt(batch.from, 16)} AND this.ECInstanceId <= ${Number.parseInt(batch.to, 16)}`,
|
|
327
|
-
};
|
|
328
|
-
return (0, rxjs_1.from)(this.getContentSet({
|
|
329
|
-
...contentOptions,
|
|
330
|
-
keys: new presentation_common_1.KeySet(),
|
|
331
|
-
descriptor: filteringDescriptor,
|
|
332
|
-
rulesetOrId: ruleset,
|
|
333
|
-
})).pipe((0, rxjs_1.map)((items) => ({ classFullName, descriptor, items })));
|
|
334
|
-
}, batchesParallelism)), classParallelism), (0, rxjs_1.map)(({ descriptor, items }) => items.map((item) => parser(descriptor, item))));
|
|
287
|
+
const batchesParallelism = workerThreadsCount > 0 ? workerThreadsCount : 1;
|
|
288
|
+
// istanbul ignore next
|
|
289
|
+
const batchSize = batchSizeOption ?? 100;
|
|
290
|
+
const elementsIdentifier = (() => {
|
|
291
|
+
if ("elementIds" in contentOptions && contentOptions.elementIds !== undefined) {
|
|
292
|
+
const elementIds = contentOptions.elementIds;
|
|
293
|
+
delete contentOptions.elementIds;
|
|
294
|
+
return { elementIds };
|
|
295
|
+
}
|
|
296
|
+
// istanbul ignore else
|
|
297
|
+
if ("elementClasses" in contentOptions && contentOptions.elementClasses !== undefined) {
|
|
298
|
+
const elementClasses = contentOptions.elementClasses;
|
|
299
|
+
delete contentOptions.elementClasses;
|
|
300
|
+
return { elementClasses };
|
|
301
|
+
}
|
|
302
|
+
// istanbul ignore next
|
|
303
|
+
return { elementClasses: ["BisCore:Element"] };
|
|
304
|
+
})();
|
|
305
|
+
const descriptorGetter = async (partialProps) => this.getContentDescriptor({ ...contentOptions, displayType: presentation_common_1.DefaultContentDisplayTypes.Grid, contentFlags: presentation_common_1.ContentFlags.ShowLabels, ...partialProps });
|
|
306
|
+
const contentSetGetter = async (partialProps) => this.getContentSet({ ...contentOptions, ...partialProps });
|
|
307
|
+
const { itemBatches, count } = "elementIds" in elementsIdentifier
|
|
308
|
+
? (0, ElementPropertiesHelper_1.getContentItemsObservableFromElementIds)(requestOptions.imodel, descriptorGetter, contentSetGetter, elementsIdentifier.elementIds, classParallelism, batchesParallelism, batchSize)
|
|
309
|
+
: (0, ElementPropertiesHelper_1.getContentItemsObservableFromClassNames)(requestOptions.imodel, descriptorGetter, contentSetGetter, elementsIdentifier.elementClasses, classParallelism, batchesParallelism, batchSize);
|
|
335
310
|
return {
|
|
336
|
-
total: (0,
|
|
311
|
+
total: await (0, rxjs_1.firstValueFrom)(count),
|
|
337
312
|
async *iterator() {
|
|
338
|
-
for await (const
|
|
339
|
-
|
|
313
|
+
for await (const itemsBatch of (0, rxjs_for_await_1.eachValueFrom)(itemBatches)) {
|
|
314
|
+
const { descriptor, items } = itemsBatch;
|
|
315
|
+
yield items.map((item) => parser(descriptor, item));
|
|
340
316
|
}
|
|
341
317
|
},
|
|
342
318
|
};
|
|
@@ -398,9 +374,7 @@ class PresentationManager {
|
|
|
398
374
|
currRulesetVariables: JSON.stringify(currRulesetVariables),
|
|
399
375
|
expandedNodeKeys: JSON.stringify(options.expandedNodeKeys ?? []),
|
|
400
376
|
};
|
|
401
|
-
|
|
402
|
-
const reviver = (key, value) => (key === "" ? presentation_common_1.HierarchyCompareInfo.fromJSON(value) : value);
|
|
403
|
-
return JSON.parse(await this._detail.request(params), reviver);
|
|
377
|
+
return JSON.parse(await this._detail.request(params));
|
|
404
378
|
}
|
|
405
379
|
}
|
|
406
380
|
exports.PresentationManager = PresentationManager;
|