@itwin/presentation-backend 4.0.0-dev.8 → 4.0.0-dev.81

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 (70) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/lib/cjs/assets/primary-presentation-rules/ElementProperties.PresentationRuleSet.json +14 -14
  3. package/lib/cjs/assets/supplemental-presentation-rules/BisCore.PresentationRuleSet.json +726 -762
  4. package/lib/cjs/assets/supplemental-presentation-rules/Functional.PresentationRuleSet.json +139 -139
  5. package/lib/cjs/presentation-backend/BackendLoggerCategory.d.ts +41 -41
  6. package/lib/cjs/presentation-backend/BackendLoggerCategory.js +50 -50
  7. package/lib/cjs/presentation-backend/BackendLoggerCategory.js.map +1 -1
  8. package/lib/cjs/presentation-backend/Constants.d.ts +8 -8
  9. package/lib/cjs/presentation-backend/Constants.js +40 -36
  10. package/lib/cjs/presentation-backend/Constants.js.map +1 -1
  11. package/lib/cjs/presentation-backend/ElementPropertiesHelper.d.ts +11 -11
  12. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js +272 -274
  13. package/lib/cjs/presentation-backend/ElementPropertiesHelper.js.map +1 -1
  14. package/lib/cjs/presentation-backend/NativePlatform.d.ts +87 -87
  15. package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
  16. package/lib/cjs/presentation-backend/NativePlatform.js +147 -140
  17. package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
  18. package/lib/cjs/presentation-backend/Presentation.d.ts +106 -106
  19. package/lib/cjs/presentation-backend/Presentation.d.ts.map +1 -1
  20. package/lib/cjs/presentation-backend/Presentation.js +148 -150
  21. package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
  22. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts +11 -12
  23. package/lib/cjs/presentation-backend/PresentationIpcHandler.d.ts.map +1 -1
  24. package/lib/cjs/presentation-backend/PresentationIpcHandler.js +30 -41
  25. package/lib/cjs/presentation-backend/PresentationIpcHandler.js.map +1 -1
  26. package/lib/cjs/presentation-backend/PresentationManager.d.ts +463 -445
  27. package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
  28. package/lib/cjs/presentation-backend/PresentationManager.js +317 -311
  29. package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
  30. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +61 -61
  31. package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
  32. package/lib/cjs/presentation-backend/PresentationManagerDetail.js +442 -430
  33. package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
  34. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +62 -62
  35. package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
  36. package/lib/cjs/presentation-backend/PresentationRpcImpl.js +388 -388
  37. package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
  38. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts +102 -102
  39. package/lib/cjs/presentation-backend/RulesetEmbedder.d.ts.map +1 -1
  40. package/lib/cjs/presentation-backend/RulesetEmbedder.js +287 -282
  41. package/lib/cjs/presentation-backend/RulesetEmbedder.js.map +1 -1
  42. package/lib/cjs/presentation-backend/RulesetManager.d.ts +53 -53
  43. package/lib/cjs/presentation-backend/RulesetManager.js +73 -73
  44. package/lib/cjs/presentation-backend/RulesetManager.js.map +1 -1
  45. package/lib/cjs/presentation-backend/RulesetVariablesManager.d.ts +140 -140
  46. package/lib/cjs/presentation-backend/RulesetVariablesManager.js +129 -129
  47. package/lib/cjs/presentation-backend/RulesetVariablesManager.js.map +1 -1
  48. package/lib/cjs/presentation-backend/SelectionScopesHelper.d.ts +28 -28
  49. package/lib/cjs/presentation-backend/SelectionScopesHelper.js +226 -229
  50. package/lib/cjs/presentation-backend/SelectionScopesHelper.js.map +1 -1
  51. package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +123 -123
  52. package/lib/cjs/presentation-backend/TemporaryStorage.js +151 -151
  53. package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
  54. package/lib/cjs/presentation-backend/UpdatesTracker.d.ts +27 -27
  55. package/lib/cjs/presentation-backend/UpdatesTracker.js +54 -54
  56. package/lib/cjs/presentation-backend/UpdatesTracker.js.map +1 -1
  57. package/lib/cjs/presentation-backend/Utils.d.ts +49 -49
  58. package/lib/cjs/presentation-backend/Utils.d.ts.map +1 -1
  59. package/lib/cjs/presentation-backend/Utils.js +107 -106
  60. package/lib/cjs/presentation-backend/Utils.js.map +1 -1
  61. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.d.ts +16 -16
  62. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js +55 -51
  63. package/lib/cjs/presentation-backend/domain/PresentationRulesDomain.js.map +1 -1
  64. package/lib/cjs/presentation-backend/domain/RulesetElements.d.ts +21 -21
  65. package/lib/cjs/presentation-backend/domain/RulesetElements.js +38 -38
  66. package/lib/cjs/presentation-backend/domain/RulesetElements.js.map +1 -1
  67. package/lib/cjs/presentation-backend.d.ts +19 -19
  68. package/lib/cjs/presentation-backend.js +39 -35
  69. package/lib/cjs/presentation-backend.js.map +1 -1
  70. package/package.json +20 -18
@@ -1 +1 @@
1
- {"version":3,"file":"NativePlatform.js","sourceRoot":"","sources":["../../../src/presentation-backend/NativePlatform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2E;AAG3E,oEAEoC;AACpC,+DAA2D;AAE3D,gBAAgB;AAChB,IAAY,0BAeX;AAfD,WAAY,0BAA0B;IACpC,2DAA6B,CAAA;IAC7B,qEAAuC,CAAA;IACvC,yDAA2B,CAAA;IAC3B,mEAAqC,CAAA;IACrC,uEAAyC,CAAA;IACzC,2DAA6B,CAAA;IAC7B,2EAA6C,CAAA;IAC7C,qEAAuC,CAAA;IACvC,2EAA6C,CAAA;IAC7C,qEAAuC,CAAA;IACvC,uDAAyB,CAAA;IACzB,+EAA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AAC,CAAC,CAAC;QAChG,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AArGW,QAAA,2BAA2B,+BAqGtC","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 { IModelDb, IModelHost, IModelJsNative } from \"@itwin/core-backend\";\r\nimport { BeEvent, IDisposable } from \"@itwin/core-bentley\";\r\nimport { FormatProps } from \"@itwin/core-quantity\";\r\nimport {\r\n DiagnosticsScopeLogs, NodeKey, PresentationError, PresentationStatus, UpdateInfoJSON, VariableValue, VariableValueJSON, VariableValueTypes,\r\n} from \"@itwin/presentation-common\";\r\nimport { HierarchyCacheMode } from \"./PresentationManager\";\r\n\r\n/** @internal */\r\nexport enum NativePlatformRequestTypes {\r\n GetRootNodes = \"GetRootNodes\",\r\n GetRootNodesCount = \"GetRootNodesCount\",\r\n GetChildren = \"GetChildren\",\r\n GetChildrenCount = \"GetChildrenCount\",\r\n GetNodesDescriptor = \"GetNodesDescriptor\",\r\n GetNodePaths = \"GetNodePaths\",\r\n GetFilteredNodePaths = \"GetFilteredNodePaths\",\r\n GetContentSources = \"GetContentSources\",\r\n GetContentDescriptor = \"GetContentDescriptor\",\r\n GetContentSetSize = \"GetContentSetSize\",\r\n GetContent = \"GetContent\",\r\n GetPagedDistinctValues = \"GetPagedDistinctValues\",\r\n GetDisplayLabel = \"GetDisplayLabel\",\r\n CompareHierarchies = \"CompareHierarchies\",\r\n}\r\n\r\n/**\r\n * Enumeration of unit systems supported by native presentation manager.\r\n * @internal\r\n */\r\nexport enum NativePresentationUnitSystem {\r\n Metric = \"metric\",\r\n BritishImperial = \"british-imperial\",\r\n UsCustomary = \"us-customary\",\r\n UsSurvey = \"us-survey\",\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePresentationDefaultUnitFormats {\r\n [phenomenon: string]: {\r\n unitSystems: NativePresentationUnitSystem[];\r\n format: FormatProps;\r\n };\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePresentationKeySetJSON {\r\n instanceKeys: Array<[string, string[]]>;\r\n nodeKeys: NodeKey[];\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePlatformResponse<TResult> {\r\n result: TResult;\r\n diagnostics?: DiagnosticsScopeLogs;\r\n}\r\n\r\n/** @internal */\r\nexport interface NativePlatformDefinition extends IDisposable {\r\n getImodelAddon(imodel: IModelDb): any;\r\n\r\n setupRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\r\n setupSupplementalRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\r\n\r\n forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>>;\r\n\r\n getRulesets(rulesetId: string): NativePlatformResponse<string>;\r\n addRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;\r\n removeRuleset(rulesetId: string, hash: string): NativePlatformResponse<boolean>;\r\n clearRulesets(): NativePlatformResponse<void>;\r\n\r\n handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>): Promise<NativePlatformResponse<string>>;\r\n\r\n getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes): NativePlatformResponse<VariableValue>;\r\n setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValue): NativePlatformResponse<void>;\r\n unsetRulesetVariableValue(rulesetId: string, variableId: string): NativePlatformResponse<void>;\r\n\r\n getUpdateInfo(): NativePlatformResponse<UpdateInfoJSON | undefined>;\r\n updateHierarchyState(db: any, rulesetId: string, stateChanges: Array<{ nodeKey: undefined | NodeKey, isExpanded?: boolean, instanceFilters?: string[] }>): NativePlatformResponse<void>;\r\n}\r\n\r\n/** @internal */\r\nexport interface DefaultNativePlatformProps {\r\n id: string;\r\n taskAllocationsMap: { [priority: number]: number };\r\n isChangeTrackingEnabled: boolean;\r\n cacheConfig?: IModelJsNative.ECPresentationHierarchyCacheConfig;\r\n contentCacheSize?: number;\r\n workerConnectionCacheSize?: number;\r\n defaultFormats?: NativePresentationDefaultUnitFormats;\r\n useMmap?: boolean | number;\r\n}\r\n\r\n/** @internal */\r\nexport const createDefaultNativePlatform = (props: DefaultNativePlatformProps): new () => NativePlatformDefinition => {\r\n // note the implementation is constructed here to make PresentationManager\r\n // usable without loading the actual addon (if addon is set to something other)\r\n return class implements NativePlatformDefinition {\r\n private _nativeAddon: IModelJsNative.ECPresentationManager;\r\n public constructor() {\r\n const cacheConfig = props.cacheConfig ?? { mode: HierarchyCacheMode.Disk, directory: \"\" };\r\n const defaultFormats = props.defaultFormats ? this.getSerializedDefaultFormatsMap(props.defaultFormats) : {};\r\n this._nativeAddon = new IModelHost.platform.ECPresentationManager({ ...props, cacheConfig, defaultFormats });\r\n }\r\n private getStatus(responseStatus: IModelJsNative.ECPresentationStatus): PresentationStatus {\r\n switch (responseStatus) {\r\n case IModelJsNative.ECPresentationStatus.InvalidArgument: return PresentationStatus.InvalidArgument;\r\n case IModelJsNative.ECPresentationStatus.Canceled: return PresentationStatus.Canceled;\r\n default: return PresentationStatus.Error;\r\n }\r\n }\r\n private getSerializedDefaultFormatsMap(defaultMap: NativePresentationDefaultUnitFormats) {\r\n const res: {\r\n [phenomenon: string]: {\r\n unitSystems: string[];\r\n serializedFormat: string;\r\n };\r\n } = {};\r\n Object.keys(defaultMap).forEach((key) => {\r\n const value = defaultMap[key];\r\n res[key] = { unitSystems: value.unitSystems, serializedFormat: JSON.stringify(value.format) };\r\n });\r\n\r\n return res;\r\n }\r\n private createSuccessResponse<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\r\n const retValue: NativePlatformResponse<T> = { result: response.result! };\r\n if (response.diagnostics)\r\n retValue.diagnostics = response.diagnostics;\r\n return retValue;\r\n }\r\n private handleResult<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\r\n if (response.error)\r\n throw new PresentationError(this.getStatus(response.error.status), response.error.message);\r\n return this.createSuccessResponse(response);\r\n }\r\n private handleVoidResult(response: IModelJsNative.ECPresentationManagerResponse<void>): NativePlatformResponse<void> {\r\n if (response.error)\r\n throw new PresentationError(this.getStatus(response.error.status), response.error.message);\r\n return this.createSuccessResponse(response);\r\n }\r\n public dispose() {\r\n this._nativeAddon.dispose();\r\n }\r\n public async forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>> {\r\n const response = await this._nativeAddon.forceLoadSchemas(db);\r\n if (response.error)\r\n throw new PresentationError(PresentationStatus.Error, response.error.message);\r\n return this.createSuccessResponse(response);\r\n }\r\n public setupRulesetDirectories(directories: string[]) {\r\n return this.handleVoidResult(this._nativeAddon.setupRulesetDirectories(directories));\r\n }\r\n public setupSupplementalRulesetDirectories(directories: string[]) {\r\n return this.handleVoidResult(this._nativeAddon.setupSupplementalRulesetDirectories(directories));\r\n }\r\n public getImodelAddon(imodel: IModelDb): any {\r\n if (!imodel.nativeDb)\r\n throw new PresentationError(PresentationStatus.InvalidArgument, \"imodel\");\r\n return imodel.nativeDb;\r\n }\r\n public getRulesets(rulesetId: string) {\r\n return this.handleResult(this._nativeAddon.getRulesets(rulesetId));\r\n }\r\n public addRuleset(serializedRulesetJson: string) {\r\n return this.handleResult(this._nativeAddon.addRuleset(serializedRulesetJson));\r\n }\r\n public removeRuleset(rulesetId: string, hash: string) {\r\n return this.handleResult(this._nativeAddon.removeRuleset(rulesetId, hash));\r\n }\r\n public clearRulesets() {\r\n return this.handleVoidResult(this._nativeAddon.clearRulesets());\r\n }\r\n public async handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>) {\r\n const response = this._nativeAddon.handleRequest(db, options);\r\n cancelEvent?.addOnce(() => response.cancel());\r\n const result = await response.result;\r\n return this.handleResult(result);\r\n }\r\n public getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes) {\r\n return this.handleResult(this._nativeAddon.getRulesetVariableValue(rulesetId, variableId, type));\r\n }\r\n public setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValueJSON) {\r\n return this.handleVoidResult(this._nativeAddon.setRulesetVariableValue(rulesetId, variableId, type, value));\r\n }\r\n public unsetRulesetVariableValue(rulesetId: string, variableId: string) {\r\n return this.handleVoidResult(this._nativeAddon.unsetRulesetVariableValue(rulesetId, variableId));\r\n }\r\n public getUpdateInfo() {\r\n return this.handleResult(this._nativeAddon.getUpdateInfo());\r\n }\r\n public updateHierarchyState(db: any, rulesetId: string, stateChanges: Array<{ nodeKey: undefined | NodeKey, isExpanded?: boolean, instanceFilter?: string }>) {\r\n return this.handleResult(this._nativeAddon.updateHierarchyState(db, rulesetId, stateChanges));\r\n }\r\n };\r\n};\r\n"]}
1
+ {"version":3,"file":"NativePlatform.js","sourceRoot":"","sources":["../../../src/presentation-backend/NativePlatform.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2E;AAC3E,sDAAmE;AAEnE,oEAEoC;AACpC,+DAA2D;AAE3D,gBAAgB;AAChB,IAAY,0BAeX;AAfD,WAAY,0BAA0B;IACpC,2DAA6B,CAAA;IAC7B,qEAAuC,CAAA;IACvC,yDAA2B,CAAA;IAC3B,mEAAqC,CAAA;IACrC,uEAAyC,CAAA;IACzC,2DAA6B,CAAA;IAC7B,2EAA6C,CAAA;IAC7C,qEAAuC,CAAA;IACvC,2EAA6C,CAAA;IAC7C,qEAAuC,CAAA;IACvC,uDAAyB,CAAA;IACzB,+EAAiD,CAAA;IACjD,iEAAmC,CAAA;IACnC,uEAAyC,CAAA;AAC3C,CAAC,EAfW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAerC;AAED;;;GAGG;AACH,IAAY,4BAKX;AALD,WAAY,4BAA4B;IACtC,iDAAiB,CAAA;IACjB,oEAAoC,CAAA;IACpC,4DAA4B,CAAA;IAC5B,sDAAsB,CAAA;AACxB,CAAC,EALW,4BAA4B,GAA5B,oCAA4B,KAA5B,oCAA4B,QAKvC;AA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,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;YAC9D,WAAW,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;YACrC,OAAO,IAAI,CAAC,YAAY,CAAS,MAAM,CAAC,CAAC;QAC3C,CAAC;QACM,uBAAuB,CAAC,SAAiB,EAAE,UAAkB,EAAE,IAAwB;YAC5F,OAAO,IAAI,CAAC,YAAY,CAAgB,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QAClH,CAAC;QACM,uBAAuB,CAAC,SAAiB,EAAE,UAAkB,EAAE,IAAwB,EAAE,KAAwB;YACtH,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,uBAAuB,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9G,CAAC;QACM,yBAAyB,CAAC,SAAiB,EAAE,UAAkB;YACpE,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,yBAAyB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;QACnG,CAAC;QACM,aAAa;YAClB,OAAO,IAAI,CAAC,YAAY,CAAyB,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA3FW,QAAA,2BAA2B,+BA2FtC","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 { IModelDb, IModelHost, IModelJsNative } from \"@itwin/core-backend\";\nimport { assert, BeEvent, IDisposable } from \"@itwin/core-bentley\";\nimport { FormatProps } from \"@itwin/core-quantity\";\nimport {\n DiagnosticsScopeLogs, NodeKey, PresentationError, PresentationStatus, UpdateInfo, VariableValue, VariableValueJSON, VariableValueTypes,\n} from \"@itwin/presentation-common\";\nimport { HierarchyCacheMode } from \"./PresentationManager\";\n\n/** @internal */\nexport enum NativePlatformRequestTypes {\n GetRootNodes = \"GetRootNodes\",\n GetRootNodesCount = \"GetRootNodesCount\",\n GetChildren = \"GetChildren\",\n GetChildrenCount = \"GetChildrenCount\",\n GetNodesDescriptor = \"GetNodesDescriptor\",\n GetNodePaths = \"GetNodePaths\",\n GetFilteredNodePaths = \"GetFilteredNodePaths\",\n GetContentSources = \"GetContentSources\",\n GetContentDescriptor = \"GetContentDescriptor\",\n GetContentSetSize = \"GetContentSetSize\",\n GetContent = \"GetContent\",\n GetPagedDistinctValues = \"GetPagedDistinctValues\",\n GetDisplayLabel = \"GetDisplayLabel\",\n CompareHierarchies = \"CompareHierarchies\",\n}\n\n/**\n * Enumeration of unit systems supported by native presentation manager.\n * @internal\n */\nexport enum NativePresentationUnitSystem {\n Metric = \"metric\",\n BritishImperial = \"british-imperial\",\n UsCustomary = \"us-customary\",\n UsSurvey = \"us-survey\",\n}\n\n/** @internal */\nexport interface NativePresentationDefaultUnitFormats {\n [phenomenon: string]: {\n unitSystems: NativePresentationUnitSystem[];\n format: FormatProps;\n };\n}\n\n/** @internal */\nexport interface NativePresentationKeySetJSON {\n instanceKeys: Array<[string, string[]]>;\n nodeKeys: NodeKey[];\n}\n\n/** @internal */\nexport interface NativePlatformResponse<TResult> {\n result: TResult;\n diagnostics?: DiagnosticsScopeLogs;\n}\n\n/** @internal */\nexport interface NativePlatformDefinition extends IDisposable {\n getImodelAddon(imodel: IModelDb): any;\n\n setupRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\n setupSupplementalRulesetDirectories(directories: string[]): NativePlatformResponse<void>;\n\n forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>>;\n\n getRulesets(rulesetId: string): NativePlatformResponse<string>;\n addRuleset(serializedRulesetJson: string): NativePlatformResponse<string>;\n removeRuleset(rulesetId: string, hash: string): NativePlatformResponse<boolean>;\n clearRulesets(): NativePlatformResponse<void>;\n\n handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>): Promise<NativePlatformResponse<string>>;\n\n getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes): NativePlatformResponse<VariableValue>;\n setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValue): NativePlatformResponse<void>;\n unsetRulesetVariableValue(rulesetId: string, variableId: string): NativePlatformResponse<void>;\n\n getUpdateInfo(): NativePlatformResponse<UpdateInfo | undefined>;\n}\n\n/** @internal */\nexport interface DefaultNativePlatformProps {\n id: string;\n taskAllocationsMap: { [priority: number]: number };\n isChangeTrackingEnabled: boolean;\n cacheConfig?: IModelJsNative.ECPresentationHierarchyCacheConfig;\n contentCacheSize?: number;\n workerConnectionCacheSize?: number;\n defaultFormats?: NativePresentationDefaultUnitFormats;\n useMmap?: boolean | number;\n}\n\n/** @internal */\nexport class PresentationNativePlatformResponseError extends PresentationError {\n public readonly diagnostics?: DiagnosticsScopeLogs;\n public constructor(errorResponse: IModelJsNative.ECPresentationManagerResponse<unknown>) {\n assert(!!errorResponse.error);\n super(getPresentationStatusFromNativeResponseStatus(errorResponse.error.status), errorResponse.error.message);\n this.diagnostics = errorResponse.diagnostics;\n }\n}\n\nfunction getPresentationStatusFromNativeResponseStatus(nativeResponseStatus: IModelJsNative.ECPresentationStatus): PresentationStatus {\n switch (nativeResponseStatus) {\n case IModelJsNative.ECPresentationStatus.InvalidArgument: return PresentationStatus.InvalidArgument;\n case IModelJsNative.ECPresentationStatus.ResultSetTooLarge: return PresentationStatus.ResultSetTooLarge;\n case IModelJsNative.ECPresentationStatus.Canceled: return PresentationStatus.Canceled;\n }\n return PresentationStatus.Error;\n}\n\n/** @internal */\nexport const createDefaultNativePlatform = (props: DefaultNativePlatformProps): new () => NativePlatformDefinition => {\n // note the implementation is constructed here to make PresentationManager\n // usable without loading the actual addon (if addon is set to something other)\n return class implements NativePlatformDefinition {\n private _nativeAddon: IModelJsNative.ECPresentationManager;\n public constructor() {\n const cacheConfig = props.cacheConfig ?? { mode: HierarchyCacheMode.Disk, directory: \"\" };\n const defaultFormats = props.defaultFormats ? this.getSerializedDefaultFormatsMap(props.defaultFormats) : {};\n this._nativeAddon = new IModelHost.platform.ECPresentationManager({ ...props, cacheConfig, defaultFormats });\n }\n private getSerializedDefaultFormatsMap(defaultMap: NativePresentationDefaultUnitFormats) {\n const res: {\n [phenomenon: string]: {\n unitSystems: string[];\n serializedFormat: string;\n };\n } = {};\n Object.keys(defaultMap).forEach((key) => {\n const value = defaultMap[key];\n res[key] = { unitSystems: value.unitSystems, serializedFormat: JSON.stringify(value.format) };\n });\n\n return res;\n }\n private createSuccessResponse<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\n const retValue: NativePlatformResponse<T> = { result: response.result! };\n if (response.diagnostics)\n retValue.diagnostics = response.diagnostics;\n return retValue;\n }\n private handleResult<T>(response: IModelJsNative.ECPresentationManagerResponse<T>): NativePlatformResponse<T> {\n if (response.error)\n throw new PresentationNativePlatformResponseError(response);\n return this.createSuccessResponse(response);\n }\n private handleVoidResult(response: IModelJsNative.ECPresentationManagerResponse<void>): NativePlatformResponse<void> {\n if (response.error)\n throw new PresentationNativePlatformResponseError(response);\n return this.createSuccessResponse(response);\n }\n public dispose() {\n this._nativeAddon.dispose();\n }\n public async forceLoadSchemas(db: any): Promise<NativePlatformResponse<void>> {\n const response = await this._nativeAddon.forceLoadSchemas(db);\n if (response.error)\n throw new PresentationError(PresentationStatus.Error, response.error.message);\n return this.createSuccessResponse(response);\n }\n public setupRulesetDirectories(directories: string[]) {\n return this.handleVoidResult(this._nativeAddon.setupRulesetDirectories(directories));\n }\n public setupSupplementalRulesetDirectories(directories: string[]) {\n return this.handleVoidResult(this._nativeAddon.setupSupplementalRulesetDirectories(directories));\n }\n public getImodelAddon(imodel: IModelDb): any {\n if (!imodel.nativeDb)\n throw new PresentationError(PresentationStatus.InvalidArgument, \"imodel\");\n return imodel.nativeDb;\n }\n public getRulesets(rulesetId: string) {\n return this.handleResult<string>(this._nativeAddon.getRulesets(rulesetId));\n }\n public addRuleset(serializedRulesetJson: string) {\n return this.handleResult<string>(this._nativeAddon.addRuleset(serializedRulesetJson));\n }\n public removeRuleset(rulesetId: string, hash: string) {\n return this.handleResult<boolean>(this._nativeAddon.removeRuleset(rulesetId, hash));\n }\n public clearRulesets() {\n return this.handleVoidResult(this._nativeAddon.clearRulesets());\n }\n public async handleRequest(db: any, options: string, cancelEvent?: BeEvent<() => void>) {\n const response = this._nativeAddon.handleRequest(db, options);\n cancelEvent?.addOnce(() => response.cancel());\n const result = await response.result;\n return this.handleResult<string>(result);\n }\n public getRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes) {\n return this.handleResult<VariableValue>(this._nativeAddon.getRulesetVariableValue(rulesetId, variableId, type));\n }\n public setRulesetVariableValue(rulesetId: string, variableId: string, type: VariableValueTypes, value: VariableValueJSON) {\n return this.handleVoidResult(this._nativeAddon.setRulesetVariableValue(rulesetId, variableId, type, value));\n }\n public unsetRulesetVariableValue(rulesetId: string, variableId: string) {\n return this.handleVoidResult(this._nativeAddon.unsetRulesetVariableValue(rulesetId, variableId));\n }\n public getUpdateInfo() {\n return this.handleResult<UpdateInfo | undefined>(this._nativeAddon.getUpdateInfo());\n }\n };\n};\n"]}
@@ -1,107 +1,107 @@
1
- /** @packageDocumentation
2
- * @module Core
3
- */
4
- import { PresentationManager, PresentationManagerProps } from "./PresentationManager";
5
- /**
6
- * Base props for initializing the [[Presentation]] library.
7
- *
8
- * @public
9
- */
10
- export interface PresentationPropsBase extends PresentationManagerProps {
11
- /**
12
- * Time in milliseconds after which the request will timeout.
13
- */
14
- requestTimeout?: number;
15
- /**
16
- * Should schemas preloading be enabled. If true, [[Presentation]] library listens
17
- * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.
18
- */
19
- enableSchemasPreload?: boolean;
20
- }
21
- /**
22
- * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]
23
- * instances, one for each frontend.
24
- *
25
- * @public
26
- */
27
- export interface MultiManagerPresentationProps extends PresentationPropsBase {
28
- /**
29
- * Factory method for creating separate managers for each client
30
- * @internal
31
- */
32
- clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;
33
- /**
34
- * How much time should an unused client manager be stored in memory
35
- * before it's disposed.
36
- */
37
- unusedClientLifetime?: number;
38
- }
39
- /**
40
- * Props for initializing the [[Presentation]] library with ability to use a single
41
- * [[PresentationManager]] instance for handling all requests.
42
- *
43
- * @public
44
- */
45
- export interface SingleManagerPresentationProps extends PresentationPropsBase {
46
- /**
47
- * Specifies to use single manager for all clients.
48
- * @alpha
49
- */
50
- useSingleManager?: boolean;
51
- }
52
- /**
53
- * Properties that can be used to configure [[Presentation]] API
54
- * @public
55
- */
56
- export declare type PresentationProps = MultiManagerPresentationProps | SingleManagerPresentationProps;
57
- /**
58
- * Static class used to statically set up Presentation library for the backend.
59
- * Basically what it does is:
60
- * - Register a RPC implementation
61
- * - Create a singleton [[PresentationManager]] instance
62
- * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate
63
- * the presentation manager when that happens.
64
- *
65
- * @public
66
- */
67
- export declare class Presentation {
68
- private static _initProps;
69
- private static _clientsStorage;
70
- private static _disposeIpcHandler;
71
- private static _shutdownListener;
72
- private static _disposeIModelOpenedListener;
73
- private static _manager;
74
- private static _rpcImpl;
75
- private constructor();
76
- /** Properties used to initialize the presentation framework */
77
- static get initProps(): PresentationProps | undefined;
78
- /**
79
- * Initializes Presentation library for the backend.
80
- *
81
- * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.
82
- *
83
- * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)
84
- *
85
- * @param props Optional properties for [[PresentationManager]]
86
- */
87
- static initialize(props?: PresentationProps): void;
88
- /**
89
- * Terminates Presentation. Consumers don't need to call this as it's automatically
90
- * called on [IModelHost.onBeforeShutdown]($core-backend) event.
91
- */
92
- static terminate(): void;
93
- private static createClientManager;
94
- private static disposeClientManager;
95
- /**
96
- * Get an instance of [[PresentationManager]] for specific client
97
- * @param clientId ID of the client requesting presentation data. If no
98
- * ID is provided, the default [[PresentationManager]] is returned.
99
- */
100
- static getManager(clientId?: string): PresentationManager;
101
- /**
102
- * Get the time in milliseconds that backend should respond in .
103
- */
104
- static getRequestTimeout(): number;
105
- private static onIModelOpened;
106
- }
1
+ /** @packageDocumentation
2
+ * @module Core
3
+ */
4
+ import { PresentationManager, PresentationManagerProps } from "./PresentationManager";
5
+ /**
6
+ * Base props for initializing the [[Presentation]] library.
7
+ *
8
+ * @public
9
+ */
10
+ export interface PresentationPropsBase extends PresentationManagerProps {
11
+ /**
12
+ * Time in milliseconds after which the request will timeout.
13
+ */
14
+ requestTimeout?: number;
15
+ /**
16
+ * Should schemas preloading be enabled. If true, [[Presentation]] library listens
17
+ * for `BriefcaseDb.onOpened` event and force pre-loads all ECSchemas.
18
+ */
19
+ enableSchemasPreload?: boolean;
20
+ }
21
+ /**
22
+ * Props for initializing the [[Presentation]] library for using multiple [[PresentationManager]]
23
+ * instances, one for each frontend.
24
+ *
25
+ * @public
26
+ */
27
+ export interface MultiManagerPresentationProps extends PresentationPropsBase {
28
+ /**
29
+ * Factory method for creating separate managers for each client
30
+ * @internal
31
+ */
32
+ clientManagerFactory?: (clientId: string, props: PresentationManagerProps) => PresentationManager;
33
+ /**
34
+ * How much time should an unused client manager be stored in memory
35
+ * before it's disposed.
36
+ */
37
+ unusedClientLifetime?: number;
38
+ }
39
+ /**
40
+ * Props for initializing the [[Presentation]] library with ability to use a single
41
+ * [[PresentationManager]] instance for handling all requests.
42
+ *
43
+ * @public
44
+ */
45
+ export interface SingleManagerPresentationProps extends PresentationPropsBase {
46
+ /**
47
+ * Specifies to use single manager for all clients.
48
+ * @alpha
49
+ */
50
+ useSingleManager?: boolean;
51
+ }
52
+ /**
53
+ * Properties that can be used to configure [[Presentation]] API
54
+ * @public
55
+ */
56
+ export type PresentationProps = MultiManagerPresentationProps | SingleManagerPresentationProps;
57
+ /**
58
+ * Static class used to statically set up Presentation library for the backend.
59
+ * Basically what it does is:
60
+ * - Register a RPC implementation
61
+ * - Create a singleton [[PresentationManager]] instance
62
+ * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate
63
+ * the presentation manager when that happens.
64
+ *
65
+ * @public
66
+ */
67
+ export declare class Presentation {
68
+ private static _initProps;
69
+ private static _clientsStorage;
70
+ private static _disposeIpcHandler;
71
+ private static _shutdownListener;
72
+ private static _disposeIModelOpenedListener;
73
+ private static _manager;
74
+ private static _rpcImpl;
75
+ private constructor();
76
+ /** Properties used to initialize the presentation framework */
77
+ static get initProps(): PresentationProps | undefined;
78
+ /**
79
+ * Initializes Presentation library for the backend.
80
+ *
81
+ * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.
82
+ *
83
+ * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)
84
+ *
85
+ * @param props Optional properties for [[PresentationManager]]
86
+ */
87
+ static initialize(props?: PresentationProps): void;
88
+ /**
89
+ * Terminates Presentation. Consumers don't need to call this as it's automatically
90
+ * called on [IModelHost.onBeforeShutdown]($core-backend) event.
91
+ */
92
+ static terminate(): void;
93
+ private static createClientManager;
94
+ private static disposeClientManager;
95
+ /**
96
+ * Get an instance of [[PresentationManager]] for specific client
97
+ * @param clientId ID of the client requesting presentation data. If no
98
+ * ID is provided, the default [[PresentationManager]] is returned.
99
+ */
100
+ static getManager(clientId?: string): PresentationManager;
101
+ /**
102
+ * Get the time in milliseconds that backend should respond in .
103
+ */
104
+ static getRequestTimeout(): number;
105
+ private static onIModelOpened;
106
+ }
107
107
  //# sourceMappingURL=Presentation.d.ts.map
@@ -1 +1 @@
1
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AiB,CAA0B;IAC1D,OAAO,CAAC,MAAM,CAAC,4BAA4B,CAA0B;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkC;IACzD,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;IAkCzD;;;OAGG;WACW,SAAS,IAAI,IAAI;IA4B/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;IAMzC,OAAO,CAAC,MAAM,CAAC,cAAc,CAK3B;CACH"}
@@ -1,151 +1,149 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module Core
8
- */
9
- var _a;
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.Presentation = void 0;
12
- const core_backend_1 = require("@itwin/core-backend");
13
- const core_bentley_1 = require("@itwin/core-bentley");
14
- const core_common_1 = require("@itwin/core-common");
15
- const presentation_common_1 = require("@itwin/presentation-common");
16
- const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
17
- const PresentationIpcHandler_1 = require("./PresentationIpcHandler");
18
- const PresentationManager_1 = require("./PresentationManager");
19
- const PresentationRpcImpl_1 = require("./PresentationRpcImpl");
20
- const TemporaryStorage_1 = require("./TemporaryStorage");
21
- const defaultRequestTimeout = 90000;
22
- /**
23
- * Static class used to statically set up Presentation library for the backend.
24
- * Basically what it does is:
25
- * - Register a RPC implementation
26
- * - Create a singleton [[PresentationManager]] instance
27
- * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate
28
- * the presentation manager when that happens.
29
- *
30
- * @public
31
- */
32
- class Presentation {
33
- /* istanbul ignore next */
34
- constructor() { }
35
- /** Properties used to initialize the presentation framework */
36
- static get initProps() { return this._initProps; }
37
- /**
38
- * Initializes Presentation library for the backend.
39
- *
40
- * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.
41
- *
42
- * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)
43
- *
44
- * @param props Optional properties for [[PresentationManager]]
45
- */
46
- static initialize(props) {
47
- var _b, _c;
48
- this._initProps = props || {};
49
- this._shutdownListener = core_backend_1.IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());
50
- this._rpcImpl = new PresentationRpcImpl_1.PresentationRpcImpl({
51
- requestTimeout: (_b = this._initProps.requestTimeout) !== null && _b !== void 0 ? _b : defaultRequestTimeout,
52
- });
53
- core_common_1.RpcManager.registerImpl(presentation_common_1.PresentationRpcInterface, PresentationRpcImpl_1.PresentationRpcImpl);
54
- core_common_1.RpcManager.supplyImplInstance(presentation_common_1.PresentationRpcInterface, this._rpcImpl);
55
- if (core_backend_1.IpcHost.isValid) {
56
- this._disposeIpcHandler = PresentationIpcHandler_1.PresentationIpcHandler.register();
57
- }
58
- if (isSingleManagerProps(this._initProps)) {
59
- this._manager = new PresentationManager_1.PresentationManager(Presentation._initProps);
60
- }
61
- else {
62
- this._clientsStorage = new TemporaryStorage_1.FactoryBasedTemporaryStorage({
63
- factory: this.createClientManager.bind(this),
64
- cleanupHandler: this.disposeClientManager,
65
- // cleanup unused managers every minute
66
- cleanupInterval: 60 * 1000,
67
- // by default, manager is disposed after 1 hour of being unused
68
- unusedValueLifetime: (_c = this._initProps.unusedClientLifetime) !== null && _c !== void 0 ? _c : 60 * 60 * 1000,
69
- // add some logging
70
- onDisposedSingle: /* istanbul ignore next */ (id) => core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage.values.length}.`),
71
- onDisposedAll: /* istanbul ignore next */ () => core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),
72
- });
73
- }
74
- if (this._initProps.enableSchemasPreload)
75
- this._disposeIModelOpenedListener = core_backend_1.BriefcaseDb.onOpened.addListener(this.onIModelOpened);
76
- }
77
- /**
78
- * Terminates Presentation. Consumers don't need to call this as it's automatically
79
- * called on [IModelHost.onBeforeShutdown]($core-backend) event.
80
- */
81
- static terminate() {
82
- if (this._clientsStorage) {
83
- this._clientsStorage.dispose();
84
- this._clientsStorage = undefined;
85
- }
86
- if (this._disposeIModelOpenedListener) {
87
- this._disposeIModelOpenedListener();
88
- this._disposeIModelOpenedListener = undefined;
89
- }
90
- if (this._shutdownListener) {
91
- this._shutdownListener();
92
- this._shutdownListener = undefined;
93
- }
94
- if (this._manager) {
95
- this._manager.dispose();
96
- this._manager = undefined;
97
- }
98
- core_common_1.RpcManager.unregisterImpl(presentation_common_1.PresentationRpcInterface);
99
- if (this._rpcImpl) {
100
- this._rpcImpl.dispose();
101
- this._rpcImpl = undefined;
102
- }
103
- if (this._disposeIpcHandler) {
104
- this._disposeIpcHandler();
105
- }
106
- this._initProps = undefined;
107
- }
108
- static createClientManager(clientId, onManagerUsed) {
109
- const manager = (Presentation._initProps && !isSingleManagerProps(Presentation._initProps) && Presentation._initProps.clientManagerFactory)
110
- ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)
111
- : new PresentationManager_1.PresentationManager(Presentation._initProps);
112
- manager.setOnManagerUsedHandler(onManagerUsed);
113
- core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage.values.length}.`);
114
- return { manager };
115
- }
116
- static disposeClientManager(_id, storeItem) {
117
- storeItem.manager.dispose();
118
- }
119
- /**
120
- * Get an instance of [[PresentationManager]] for specific client
121
- * @param clientId ID of the client requesting presentation data. If no
122
- * ID is provided, the default [[PresentationManager]] is returned.
123
- */
124
- static getManager(clientId) {
125
- if (this._initProps && isSingleManagerProps(this._initProps) && this._manager)
126
- return this._manager;
127
- if (this._clientsStorage)
128
- return this._clientsStorage.getValue(clientId || "").manager;
129
- throw new presentation_common_1.PresentationError(presentation_common_1.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 presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.NotInitialized, "Presentation must be first initialized by calling Presentation.initialize");
137
- return this._rpcImpl.requestTimeout;
138
- }
139
- }
140
- exports.Presentation = Presentation;
141
- _a = Presentation;
142
- Presentation.onIModelOpened = (imodel) => {
143
- const manager = _a.getManager();
144
- const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);
145
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
146
- manager.getNativePlatform().forceLoadSchemas(imodelAddon);
147
- };
148
- function isSingleManagerProps(props) {
149
- return !!props.useSingleManager;
150
- }
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Core
8
+ */
9
+ var _a;
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.Presentation = void 0;
12
+ const core_backend_1 = require("@itwin/core-backend");
13
+ const core_bentley_1 = require("@itwin/core-bentley");
14
+ const core_common_1 = require("@itwin/core-common");
15
+ const presentation_common_1 = require("@itwin/presentation-common");
16
+ const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
17
+ const PresentationIpcHandler_1 = require("./PresentationIpcHandler");
18
+ const PresentationManager_1 = require("./PresentationManager");
19
+ const PresentationRpcImpl_1 = require("./PresentationRpcImpl");
20
+ const TemporaryStorage_1 = require("./TemporaryStorage");
21
+ /**
22
+ * Static class used to statically set up Presentation library for the backend.
23
+ * Basically what it does is:
24
+ * - Register a RPC implementation
25
+ * - Create a singleton [[PresentationManager]] instance
26
+ * - Subscribe for [IModelHost.onBeforeShutdown]($core-backend) event and terminate
27
+ * the presentation manager when that happens.
28
+ *
29
+ * @public
30
+ */
31
+ class Presentation {
32
+ /* istanbul ignore next */
33
+ constructor() { }
34
+ /** Properties used to initialize the presentation framework */
35
+ static get initProps() { return this._initProps; }
36
+ /**
37
+ * Initializes Presentation library for the backend.
38
+ *
39
+ * See [Setting up iTwin.js Presentation library documentation page]($docs/presentation/setup/index.md#backend) for an example.
40
+ *
41
+ * **Important:** The method should be called after a call to [IModelHost.startup]($core-backend)
42
+ *
43
+ * @param props Optional properties for [[PresentationManager]]
44
+ */
45
+ static initialize(props) {
46
+ this._initProps = props || {};
47
+ this._shutdownListener = core_backend_1.IModelHost.onBeforeShutdown.addListener(() => Presentation.terminate());
48
+ this._rpcImpl = new PresentationRpcImpl_1.PresentationRpcImpl({
49
+ requestTimeout: this._initProps.requestTimeout,
50
+ });
51
+ core_common_1.RpcManager.registerImpl(presentation_common_1.PresentationRpcInterface, PresentationRpcImpl_1.PresentationRpcImpl);
52
+ core_common_1.RpcManager.supplyImplInstance(presentation_common_1.PresentationRpcInterface, this._rpcImpl);
53
+ if (core_backend_1.IpcHost.isValid) {
54
+ this._disposeIpcHandler = PresentationIpcHandler_1.PresentationIpcHandler.register();
55
+ }
56
+ if (isSingleManagerProps(this._initProps)) {
57
+ this._manager = new PresentationManager_1.PresentationManager(Presentation._initProps);
58
+ }
59
+ else {
60
+ this._clientsStorage = new TemporaryStorage_1.FactoryBasedTemporaryStorage({
61
+ factory: this.createClientManager.bind(this),
62
+ cleanupHandler: this.disposeClientManager,
63
+ // cleanup unused managers every minute
64
+ cleanupInterval: 60 * 1000,
65
+ // by default, manager is disposed after 1 hour of being unused
66
+ unusedValueLifetime: this._initProps.unusedClientLifetime ?? 60 * 60 * 1000,
67
+ // add some logging
68
+ onDisposedSingle: /* istanbul ignore next */ (id) => core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Disposed PresentationManager instance with ID: ${id}. Total instances: ${this._clientsStorage.values.length}.`),
69
+ onDisposedAll: /* istanbul ignore next */ () => core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Disposed all PresentationManager instances.`),
70
+ });
71
+ }
72
+ if (this._initProps.enableSchemasPreload)
73
+ this._disposeIModelOpenedListener = core_backend_1.BriefcaseDb.onOpened.addListener(this.onIModelOpened);
74
+ }
75
+ /**
76
+ * Terminates Presentation. Consumers don't need to call this as it's automatically
77
+ * called on [IModelHost.onBeforeShutdown]($core-backend) event.
78
+ */
79
+ static terminate() {
80
+ if (this._clientsStorage) {
81
+ this._clientsStorage.dispose();
82
+ this._clientsStorage = undefined;
83
+ }
84
+ if (this._disposeIModelOpenedListener) {
85
+ this._disposeIModelOpenedListener();
86
+ this._disposeIModelOpenedListener = undefined;
87
+ }
88
+ if (this._shutdownListener) {
89
+ this._shutdownListener();
90
+ this._shutdownListener = undefined;
91
+ }
92
+ if (this._manager) {
93
+ this._manager.dispose();
94
+ this._manager = undefined;
95
+ }
96
+ core_common_1.RpcManager.unregisterImpl(presentation_common_1.PresentationRpcInterface);
97
+ if (this._rpcImpl) {
98
+ this._rpcImpl.dispose();
99
+ this._rpcImpl = undefined;
100
+ }
101
+ if (this._disposeIpcHandler) {
102
+ this._disposeIpcHandler();
103
+ }
104
+ this._initProps = undefined;
105
+ }
106
+ static createClientManager(clientId, onManagerUsed) {
107
+ const manager = (Presentation._initProps && !isSingleManagerProps(Presentation._initProps) && Presentation._initProps.clientManagerFactory)
108
+ ? Presentation._initProps.clientManagerFactory(clientId, Presentation._initProps)
109
+ : new PresentationManager_1.PresentationManager({ ...Presentation._initProps, id: clientId });
110
+ manager.setOnManagerUsedHandler(onManagerUsed);
111
+ core_bentley_1.Logger.logInfo(BackendLoggerCategory_1.PresentationBackendLoggerCategory.PresentationManager, `Created a PresentationManager instance with ID: ${clientId}. Total instances: ${this._clientsStorage.values.length}.`);
112
+ return { manager };
113
+ }
114
+ static disposeClientManager(_id, storeItem) {
115
+ storeItem.manager.dispose();
116
+ }
117
+ /**
118
+ * Get an instance of [[PresentationManager]] for specific client
119
+ * @param clientId ID of the client requesting presentation data. If no
120
+ * ID is provided, the default [[PresentationManager]] is returned.
121
+ */
122
+ static getManager(clientId) {
123
+ if (this._initProps && isSingleManagerProps(this._initProps) && this._manager)
124
+ return this._manager;
125
+ if (this._clientsStorage)
126
+ return this._clientsStorage.getValue(clientId || "").manager;
127
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.NotInitialized, "Presentation must be first initialized by calling Presentation.initialize");
128
+ }
129
+ /**
130
+ * Get the time in milliseconds that backend should respond in .
131
+ */
132
+ static getRequestTimeout() {
133
+ if (this._rpcImpl === undefined)
134
+ throw new presentation_common_1.PresentationError(presentation_common_1.PresentationStatus.NotInitialized, "Presentation must be first initialized by calling Presentation.initialize");
135
+ return this._rpcImpl.requestTimeout;
136
+ }
137
+ }
138
+ _a = Presentation;
139
+ Presentation.onIModelOpened = (imodel) => {
140
+ const manager = _a.getManager();
141
+ const imodelAddon = manager.getNativePlatform().getImodelAddon(imodel);
142
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
143
+ manager.getNativePlatform().forceLoadSchemas(imodelAddon);
144
+ };
145
+ exports.Presentation = Presentation;
146
+ function isSingleManagerProps(props) {
147
+ return !!props.useSingleManager;
148
+ }
151
149
  //# sourceMappingURL=Presentation.js.map