@itwin/presentation-backend 5.0.0-dev.11 → 5.0.0-dev.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/lib/cjs/package.json +1 -0
  3. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +31 -4
  4. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -1
  5. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +161 -56
  6. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  7. package/lib/cjs/presentation-backend/InternalSymbols.d.ts +5 -0
  8. package/lib/cjs/presentation-backend/InternalSymbols.d.ts.map +1 -0
  9. package/lib/cjs/presentation-backend/InternalSymbols.js +16 -0
  10. package/lib/cjs/presentation-backend/InternalSymbols.js.map +1 -0
  11. package/lib/cjs/presentation-backend/NativePlatform.d.ts +2 -2
  12. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  13. package/lib/cjs/presentation-backend/NativePlatform.js +5 -3
  14. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  15. package/lib/cjs/presentation-backend/Presentation.d.ts +2 -7
  16. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  17. package/lib/cjs/presentation-backend/Presentation.js +40 -29
  18. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  19. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +3 -3
  20. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
  21. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +5 -7
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  23. package/lib/cjs/presentation-backend/PresentationManager.d.ts +13 -90
  24. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  25. package/lib/cjs/presentation-backend/PresentationManager.js +79 -130
  26. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  27. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +19 -10
  28. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
  29. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +83 -76
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  31. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +11 -11
  32. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  33. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +110 -118
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  35. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  36. package/lib/cjs/presentation-backend/RulesetEmbedder.js +23 -24
  37. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetManager.d.ts +1 -1
  39. package/lib/cjs/presentation-backend/RulesetManager.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/RulesetManager.js +2 -1
  41. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  42. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +1 -1
  43. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts.map +1 -1
  44. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +2 -0
  45. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  46. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +2 -4
  47. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts.map +1 -1
  48. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +70 -83
  49. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  50. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +2 -3
  51. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
  52. package/lib/cjs/presentation-backend/TemporaryStorage.js +30 -28
  53. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  54. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  55. package/lib/cjs/presentation-backend/Utils.js +15 -21
  56. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  57. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +2 -2
  58. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  59. package/lib/cjs/presentation-backend/domain/RulesetElements.js +4 -4
  60. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  61. package/lib/cjs/presentation-backend-internal.d.ts +2 -0
  62. package/lib/cjs/presentation-backend-internal.d.ts.map +1 -0
  63. package/lib/cjs/presentation-backend-internal.js +12 -0
  64. package/lib/cjs/presentation-backend-internal.js.map +1 -0
  65. package/lib/cjs/presentation-backend.d.ts +7 -7
  66. package/lib/cjs/presentation-backend.d.ts.map +1 -1
  67. package/lib/cjs/presentation-backend.js +11 -21
  68. package/lib/cjs/presentation-backend.js.map +1 -1
  69. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts +62 -0
  70. package/lib/esm/presentation-backend/BackendLoggerCategory.d.ts.map +1 -0
  71. package/lib/esm/presentation-backend/BackendLoggerCategory.js +69 -0
  72. package/lib/esm/presentation-backend/BackendLoggerCategory.js.map +1 -0
  73. package/lib/esm/presentation-backend/ElementPropertiesHelper.d.ts +45 -0
  74. package/lib/esm/presentation-backend/ElementPropertiesHelper.d.ts.map +1 -0
  75. package/lib/esm/presentation-backend/ElementPropertiesHelper.js +187 -0
  76. package/lib/esm/presentation-backend/ElementPropertiesHelper.js.map +1 -0
  77. package/lib/esm/presentation-backend/InternalSymbols.d.ts +5 -0
  78. package/lib/esm/presentation-backend/InternalSymbols.d.ts.map +1 -0
  79. package/lib/esm/presentation-backend/InternalSymbols.js +13 -0
  80. package/lib/esm/presentation-backend/InternalSymbols.js.map +1 -0
  81. package/lib/esm/presentation-backend/NativePlatform.d.ts +89 -0
  82. package/lib/esm/presentation-backend/NativePlatform.d.ts.map +1 -0
  83. package/lib/esm/presentation-backend/NativePlatform.js +156 -0
  84. package/lib/esm/presentation-backend/NativePlatform.js.map +1 -0
  85. package/lib/esm/presentation-backend/Presentation.d.ts +97 -0
  86. package/lib/esm/presentation-backend/Presentation.d.ts.map +1 -0
  87. package/lib/esm/presentation-backend/Presentation.js +147 -0
  88. package/lib/esm/presentation-backend/Presentation.js.map +1 -0
  89. package/lib/esm/presentation-backend/PresentationIpcHandler.d.ts +12 -0
  90. package/lib/esm/presentation-backend/PresentationIpcHandler.d.ts.map +1 -0
  91. package/lib/esm/presentation-backend/PresentationIpcHandler.js +25 -0
  92. package/lib/esm/presentation-backend/PresentationIpcHandler.js.map +1 -0
  93. package/lib/esm/presentation-backend/PresentationManager.d.ts +387 -0
  94. package/lib/esm/presentation-backend/PresentationManager.d.ts.map +1 -0
  95. package/lib/esm/presentation-backend/PresentationManager.js +352 -0
  96. package/lib/esm/presentation-backend/PresentationManager.js.map +1 -0
  97. package/lib/esm/presentation-backend/PresentationManagerDetail.d.ts +74 -0
  98. package/lib/esm/presentation-backend/PresentationManagerDetail.d.ts.map +1 -0
  99. package/lib/esm/presentation-backend/PresentationManagerDetail.js +446 -0
  100. package/lib/esm/presentation-backend/PresentationManagerDetail.js.map +1 -0
  101. package/lib/esm/presentation-backend/PresentationRpcImpl.d.ts +63 -0
  102. package/lib/esm/presentation-backend/PresentationRpcImpl.d.ts.map +1 -0
  103. package/lib/esm/presentation-backend/PresentationRpcImpl.js +409 -0
  104. package/lib/esm/presentation-backend/PresentationRpcImpl.js.map +1 -0
  105. package/lib/esm/presentation-backend/RulesetEmbedder.d.ts +109 -0
  106. package/lib/esm/presentation-backend/RulesetEmbedder.d.ts.map +1 -0
  107. package/lib/esm/presentation-backend/RulesetEmbedder.js +269 -0
  108. package/lib/esm/presentation-backend/RulesetEmbedder.js.map +1 -0
  109. package/lib/esm/presentation-backend/RulesetManager.d.ts +54 -0
  110. package/lib/esm/presentation-backend/RulesetManager.d.ts.map +1 -0
  111. package/lib/esm/presentation-backend/RulesetManager.js +74 -0
  112. package/lib/esm/presentation-backend/RulesetManager.js.map +1 -0
  113. package/lib/esm/presentation-backend/RulesetVariablesManager.d.ts +141 -0
  114. package/lib/esm/presentation-backend/RulesetVariablesManager.d.ts.map +1 -0
  115. package/lib/esm/presentation-backend/RulesetVariablesManager.js +140 -0
  116. package/lib/esm/presentation-backend/RulesetVariablesManager.js.map +1 -0
  117. package/lib/esm/presentation-backend/SelectionScopesHelper.d.ts +27 -0
  118. package/lib/esm/presentation-backend/SelectionScopesHelper.d.ts.map +1 -0
  119. package/lib/esm/presentation-backend/SelectionScopesHelper.js +227 -0
  120. package/lib/esm/presentation-backend/SelectionScopesHelper.js.map +1 -0
  121. package/lib/esm/presentation-backend/TemporaryStorage.d.ts +123 -0
  122. package/lib/esm/presentation-backend/TemporaryStorage.d.ts.map +1 -0
  123. package/lib/esm/presentation-backend/TemporaryStorage.js +157 -0
  124. package/lib/esm/presentation-backend/TemporaryStorage.js.map +1 -0
  125. package/lib/esm/presentation-backend/Utils.d.ts +50 -0
  126. package/lib/esm/presentation-backend/Utils.d.ts.map +1 -0
  127. package/lib/esm/presentation-backend/Utils.js +101 -0
  128. package/lib/esm/presentation-backend/Utils.js.map +1 -0
  129. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.d.ts +17 -0
  130. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.d.ts.map +1 -0
  131. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.js +31 -0
  132. package/lib/esm/presentation-backend/domain/PresentationRulesDomain.js.map +1 -0
  133. package/lib/esm/presentation-backend/domain/RulesetElements.d.ts +22 -0
  134. package/lib/esm/presentation-backend/domain/RulesetElements.d.ts.map +1 -0
  135. package/lib/esm/presentation-backend/domain/RulesetElements.js +38 -0
  136. package/lib/esm/presentation-backend/domain/RulesetElements.js.map +1 -0
  137. package/lib/esm/presentation-backend/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -0
  138. package/lib/esm/presentation-backend/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +701 -0
  139. package/lib/esm/presentation-backend/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -0
  140. package/lib/esm/presentation-backend-internal.d.ts +2 -0
  141. package/lib/esm/presentation-backend-internal.d.ts.map +1 -0
  142. package/lib/esm/presentation-backend-internal.js +8 -0
  143. package/lib/esm/presentation-backend-internal.js.map +1 -0
  144. package/lib/esm/presentation-backend.d.ts +20 -0
  145. package/lib/esm/presentation-backend.d.ts.map +1 -0
  146. package/lib/esm/presentation-backend.js +21 -0
  147. package/lib/esm/presentation-backend.js.map +1 -0
  148. package/package.json +42 -35
@@ -0,0 +1,97 @@
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ import { PresentationManager, PresentationManagerProps } from "./PresentationManager.js";
5
+ /**
6
+ * Properties that can be used to configure [[Presentation]] API.
7
+ * @public
8
+ */
9
+ export interface PresentationProps extends Omit<PresentationManagerProps, "enableSchemasPreload"> {
10
+ /**
11
+ * Time in milliseconds after which the request will timeout.
12
+ */
13
+ requestTimeout?: number;
14
+ /**
15
+ * Should schemas preloading be enabled. If true, [[Presentation]] library listens
16
+ * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.
17
+ */
18
+ enableSchemasPreload?: boolean;
19
+ /**
20
+ * How much time should an unused client manager be stored in memory
21
+ * before it's disposed.
22
+ */
23
+ unusedClientLifetime?: number;
24
+ }
25
+ /**
26
+ * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]
27
+ * instances, one for each frontend.
28
+ *
29
+ * @public
30
+ * @deprecated in 4.8 - use [[PresentationProps]] instead.
31
+ */
32
+ export type MultiManagerPresentationProps = PresentationProps;
33
+ /**
34
+ * Base props for initializing the [[Presentation]] library.
35
+ *
36
+ * @public
37
+ * @deprecated in 4.8 - use [[PresentationProps]] instead.
38
+ */
39
+ export type PresentationPropsBase = PresentationProps;
40
+ /**
41
+ * Props for initializing the [[Presentation]] library with ability to use a single
42
+ * [[PresentationManager]] instance for handling all requests.
43
+ *
44
+ * @public
45
+ * @deprecated in 4.8 - use [[PresentationProps]] instead.
46
+ */
47
+ export type SingleManagerPresentationProps = Omit<PresentationProps, "unusedClientLifetime">;
48
+ /**
49
+ * Static class used to statically set up Presentation library for the backend.
50
+ * Basically what it does is:
51
+ * - Register a RPC implementation
52
+ * - Create a singleton [[PresentationManager]] instance
53
+ * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate
54
+ * the presentation manager when that happens.
55
+ *
56
+ * @public
57
+ */
58
+ export declare class Presentation {
59
+ private static _initProps;
60
+ private static _clientsStorage;
61
+ private static _disposeIpcHandler;
62
+ private static _shutdownListener;
63
+ private static _disposeIModelOpenedListener;
64
+ private static _rpcImpl;
65
+ private constructor();
66
+ /** Properties used to initialize the presentation framework */
67
+ static get initProps(): PresentationProps | undefined;
68
+ /**
69
+ * Initializes Presentation library for the backend.
70
+ *
71
+ * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.
72
+ *
73
+ * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)
74
+ *
75
+ * @param props Optional properties for [[PresentationManager]]
76
+ */
77
+ static initialize(props?: PresentationProps): void;
78
+ /**
79
+ * Terminates Presentation. Consumers don't need to call this as it's automatically
80
+ * called on [IModelHost.onBeforeShutdown]($core-backend) event.
81
+ */
82
+ static terminate(): void;
83
+ private static createClientManager;
84
+ private static disposeClientManager;
85
+ /**
86
+ * Get an instance of [[PresentationManager]] for specific client
87
+ * @param clientId ID of the client requesting presentation data. If no
88
+ * ID is provided, the default [[PresentationManager]] is returned.
89
+ */
90
+ static getManager(clientId?: string): PresentationManager;
91
+ /**
92
+ * Get the time in milliseconds that backend should respond in .
93
+ */
94
+ static getRequestTimeout(): number;
95
+ private static onIModelOpened;
96
+ }
97
+ //# sourceMappingURL=Presentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Presentation.d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AC,QAAQ,CAAC,EAAE,MAAM,GAAG,mBAAmB;IAOhE;;OAEG;WACW,iBAAiB,IAAI,MAAM;IAOzC,OAAO,CAAC,MAAM,CAAC,cAAc,CAK3B;CACH"}
@@ -0,0 +1,147 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module Core
7
+ */
8
+ import { BriefcaseDb, IModelHost, IpcHost } from "@itwin/core-backend";
9
+ import { Logger } from "@itwin/core-bentley";
10
+ import { RpcManager } from "@itwin/core-common";
11
+ import { PresentationError, PresentationRpcInterface, PresentationStatus } from "@itwin/presentation-common";
12
+ import { PresentationBackendLoggerCategory } from "./BackendLoggerCategory.js";
13
+ import { PresentationIpcHandler } from "./PresentationIpcHandler.js";
14
+ import { PresentationManager } from "./PresentationManager.js";
15
+ import { PresentationRpcImpl } from "./PresentationRpcImpl.js";
16
+ import { FactoryBasedTemporaryStorage } from "./TemporaryStorage.js";
17
+ import { _presentation_manager_detail } from "./InternalSymbols.js";
18
+ /**
19
+ * Static class used to statically set up Presentation library for the backend.
20
+ * Basically what it does is:
21
+ * - Register a RPC implementation
22
+ * - Create a singleton [[PresentationManager]] instance
23
+ * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate
24
+ * the presentation manager when that happens.
25
+ *
26
+ * @public
27
+ */
28
+ export class Presentation {
29
+ static _initProps;
30
+ static _clientsStorage;
31
+ static _disposeIpcHandler;
32
+ static _shutdownListener;
33
+ static _disposeIModelOpenedListener;
34
+ static _rpcImpl;
35
+ /* c8 ignore next */
36
+ constructor() { }
37
+ /** Properties used to initialize the presentation framework */
38
+ static get initProps() {
39
+ return this._initProps;
40
+ }
41
+ /**
42
+ * Initializes Presentation library for the backend.
43
+ *
44
+ * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.
45
+ *
46
+ * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)
47
+ *
48
+ * @param props Optional properties for [[PresentationManager]]
49
+ */
50
+ static initialize(props) {
51
+ this._initProps = props || {};
52
+ this._shutdownListener = IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());
53
+ this._rpcImpl = new PresentationRpcImpl({
54
+ requestTimeout: this._initProps.requestTimeout,
55
+ });
56
+ RpcManager.registerImpl(PresentationRpcInterface, PresentationRpcImpl);
57
+ RpcManager.supplyImplInstance(PresentationRpcInterface, this._rpcImpl);
58
+ if (IpcHost.isValid) {
59
+ this._disposeIpcHandler = PresentationIpcHandler.register();
60
+ }
61
+ this._clientsStorage = new FactoryBasedTemporaryStorage({
62
+ factory: this.createClientManager.bind(this),
63
+ cleanupHandler: (_id, storeItem) => this.disposeClientManager(_id, storeItem),
64
+ // cleanup unused managers every minute
65
+ cleanupInterval: 60 * 1000,
66
+ // by default, manager is disposed after 1 hour of being unused
67
+ unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,
68
+ // add some logging
69
+ /* c8 ignore next 5 */
70
+ onDisposedSingle: (id) => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage.values.length}.`),
71
+ /* c8 ignore next */
72
+ onDisposedAll: () => Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),
73
+ });
74
+ if (this._initProps.enableSchemasPreload) {
75
+ this._disposeIModelOpenedListener = BriefcaseDb.onOpened.addListener(this.onIModelOpened);
76
+ }
77
+ }
78
+ /**
79
+ * Terminates Presentation. Consumers don't need to call this as it's automatically
80
+ * called on [IModelHost.onBeforeShutdown]($core-backend) event.
81
+ */
82
+ static terminate() {
83
+ if (this._clientsStorage) {
84
+ this._clientsStorage[Symbol.dispose]();
85
+ this._clientsStorage = undefined;
86
+ }
87
+ if (this._disposeIModelOpenedListener) {
88
+ this._disposeIModelOpenedListener();
89
+ this._disposeIModelOpenedListener = undefined;
90
+ }
91
+ if (this._shutdownListener) {
92
+ this._shutdownListener();
93
+ this._shutdownListener = undefined;
94
+ }
95
+ RpcManager.unregisterImpl(PresentationRpcInterface);
96
+ if (this._rpcImpl) {
97
+ this._rpcImpl[Symbol.dispose]();
98
+ this._rpcImpl = undefined;
99
+ }
100
+ if (this._disposeIpcHandler) {
101
+ this._disposeIpcHandler();
102
+ }
103
+ this._initProps = undefined;
104
+ }
105
+ static createClientManager(clientId, onManagerUsed) {
106
+ const manager = Presentation._initProps && Presentation._initProps.clientManagerFactory
107
+ ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)
108
+ : new PresentationManager({
109
+ ...Presentation._initProps,
110
+ // @ts-expect-error internal prop
111
+ id: clientId,
112
+ });
113
+ manager.onUsed.addListener(onManagerUsed);
114
+ Logger.logInfo(PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage.values.length}.`);
115
+ return { manager };
116
+ }
117
+ static disposeClientManager(_id, storeItem) {
118
+ storeItem.manager[Symbol.dispose]();
119
+ }
120
+ /**
121
+ * Get an instance of [[PresentationManager]] for specific client
122
+ * @param clientId ID of the client requesting presentation data. If no
123
+ * ID is provided, the default [[PresentationManager]] is returned.
124
+ */
125
+ static getManager(clientId) {
126
+ if (this._clientsStorage) {
127
+ return this._clientsStorage.getValue(clientId || "").manager;
128
+ }
129
+ throw new PresentationError(PresentationStatus.NotInitialized, "Presentation must be first initialized by calling Presentation.initialize");
130
+ }
131
+ /**
132
+ * Get the time in milliseconds that backend should respond in .
133
+ */
134
+ static getRequestTimeout() {
135
+ if (this._rpcImpl === undefined) {
136
+ throw new PresentationError(PresentationStatus.NotInitialized, "Presentation must be first initialized by calling Presentation.initialize");
137
+ }
138
+ return this._rpcImpl.requestTimeout;
139
+ }
140
+ static onIModelOpened = (imodel) => {
141
+ const manager = this.getManager();
142
+ const imodelAddon = manager[_presentation_manager_detail].getNativePlatform().getImodelAddon(imodel);
143
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
144
+ manager[_presentation_manager_detail].getNativePlatform().forceLoadSchemas(imodelAddon);
145
+ };
146
+ }
147
+ //# sourceMappingURL=Presentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Presentation.js","sourceRoot":"","sources":["../../../src/presentation-backend/Presentation.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAe,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC7G,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAA4B,MAAM,0BAA0B,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AA8DpE;;;;;;;;;GASG;AACH,MAAM,OAAO,YAAY;IACf,MAAM,CAAC,UAAU,CAA8D;IAC/E,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,oBAAoB;IACpB,gBAAuB,CAAC;IAExB,+DAA+D;IACxD,MAAM,KAAK,SAAS;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC;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AG,CAAC,MAAmB,EAAE,EAAE;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC,iBAAiB,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACrG,mEAAmE;QACnE,OAAO,CAAC,4BAA4B,CAAC,CAAC,iBAAiB,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC1F,CAAC,CAAC","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.js\";\r\nimport { PresentationIpcHandler } from \"./PresentationIpcHandler.js\";\r\nimport { PresentationManager, PresentationManagerProps } from \"./PresentationManager.js\";\r\nimport { PresentationRpcImpl } from \"./PresentationRpcImpl.js\";\r\nimport { FactoryBasedTemporaryStorage } from \"./TemporaryStorage.js\";\r\nimport { _presentation_manager_detail } from \"./InternalSymbols.js\";\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 * 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\ninterface PresentationInternalProps {\r\n /**\r\n * Factory method for creating separate managers for each client\r\n */\r\n clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;\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, \"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 & PresentationInternalProps) | 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 /* c8 ignore next */\r\n private constructor() {}\r\n\r\n /** Properties used to initialize the presentation framework */\r\n public static get initProps(): PresentationProps | undefined {\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 /* c8 ignore next 5 */\r\n onDisposedSingle: (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 /* c8 ignore next */\r\n onDisposedAll: () => 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[Symbol.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[Symbol.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({\r\n ...Presentation._initProps,\r\n // @ts-expect-error internal prop\r\n id: clientId,\r\n });\r\n manager.onUsed.addListener(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[Symbol.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[_presentation_manager_detail].getNativePlatform().getImodelAddon(imodel);\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n manager[_presentation_manager_detail].getNativePlatform().forceLoadSchemas(imodelAddon);\r\n };\r\n}\r\n"]}
@@ -0,0 +1,12 @@
1
+ /** @packageDocumentation
2
+ * @module RPC
3
+ */
4
+ import { IpcHandler } from "@itwin/core-backend";
5
+ import { PresentationIpcInterface } from "@itwin/presentation-common/internal";
6
+ /** @internal */
7
+ export declare class PresentationIpcHandler extends IpcHandler implements PresentationIpcInterface {
8
+ channelName: string;
9
+ setRulesetVariable(params: Parameters<PresentationIpcInterface["setRulesetVariable"]>[0]): Promise<void>;
10
+ unsetRulesetVariable(params: Parameters<PresentationIpcInterface["unsetRulesetVariable"]>[0]): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=PresentationIpcHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PresentationIpcHandler.d.ts","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAiC,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAG9G,gBAAgB;AAChB,qBAAa,sBAAuB,SAAQ,UAAW,YAAW,wBAAwB;IACjF,WAAW,SAAiC;IAEtC,kBAAkB,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxG,oBAAoB,CAAC,MAAM,EAAE,UAAU,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAI1H"}
@@ -0,0 +1,25 @@
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module RPC
7
+ */
8
+ import { IpcHandler } from "@itwin/core-backend";
9
+ import { RulesetVariable } from "@itwin/presentation-common";
10
+ import { PRESENTATION_IPC_CHANNEL_NAME } from "@itwin/presentation-common/internal";
11
+ import { Presentation } from "./Presentation.js";
12
+ /** @internal */
13
+ export class PresentationIpcHandler extends IpcHandler {
14
+ channelName = PRESENTATION_IPC_CHANNEL_NAME;
15
+ async setRulesetVariable(params) {
16
+ const { clientId, rulesetId, variable } = params;
17
+ const parsedVariable = RulesetVariable.fromJSON(variable);
18
+ Presentation.getManager(clientId).vars(rulesetId).setValue(parsedVariable.id, parsedVariable.type, parsedVariable.value);
19
+ }
20
+ async unsetRulesetVariable(params) {
21
+ const { clientId, rulesetId, variableId } = params;
22
+ Presentation.getManager(clientId).vars(rulesetId).unset(variableId);
23
+ }
24
+ }
25
+ //# sourceMappingURL=PresentationIpcHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PresentationIpcHandler.js","sourceRoot":"","sources":["../../../src/presentation-backend/PresentationIpcHandler.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,6BAA6B,EAA4B,MAAM,qCAAqC,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,gBAAgB;AAChB,MAAM,OAAO,sBAAuB,SAAQ,UAAU;IAC7C,WAAW,GAAG,6BAA6B,CAAC;IAE5C,KAAK,CAAC,kBAAkB,CAAC,MAAqE;QACnG,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QACjD,MAAM,cAAc,GAAG,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1D,YAAY,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,MAAuE;QACvG,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;QACnD,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n * See LICENSE.md in the project root for license terms and full copyright notice.\r\n *--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module RPC\r\n */\r\n\r\nimport { IpcHandler } from \"@itwin/core-backend\";\r\nimport { RulesetVariable } from \"@itwin/presentation-common\";\r\nimport { PRESENTATION_IPC_CHANNEL_NAME, PresentationIpcInterface } from \"@itwin/presentation-common/internal\";\r\nimport { Presentation } from \"./Presentation.js\";\r\n\r\n/** @internal */\r\nexport class PresentationIpcHandler extends IpcHandler implements PresentationIpcInterface {\r\n public channelName = PRESENTATION_IPC_CHANNEL_NAME;\r\n\r\n public async setRulesetVariable(params: Parameters<PresentationIpcInterface[\"setRulesetVariable\"]>[0]): Promise<void> {\r\n const { clientId, rulesetId, variable } = params;\r\n const parsedVariable = RulesetVariable.fromJSON(variable);\r\n Presentation.getManager(clientId).vars(rulesetId).setValue(parsedVariable.id, parsedVariable.type, parsedVariable.value);\r\n }\r\n\r\n public async unsetRulesetVariable(params: Parameters<PresentationIpcInterface[\"unsetRulesetVariable\"]>[0]): Promise<void> {\r\n const { clientId, rulesetId, variableId } = params;\r\n Presentation.getManager(clientId).vars(rulesetId).unset(variableId);\r\n }\r\n}\r\n"]}