UNPKG

@itwin/core-backend

Version:
43 lines 1.63 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module IModelHost */ import { NativeLibrary } from "@bentley/imodeljs-native"; import { Logger, ProcessDetector } from "@itwin/core-bentley"; let nativePlatform; let syncNativeLogLevelsOverride; function syncNativeLogLevels() { if (syncNativeLogLevelsOverride) { syncNativeLogLevelsOverride(); } else { nativePlatform?.clearLogLevelCache(); } } /** Provides access to the internal APIs defined in @bentley/imodeljs-native. * @internal */ export class IModelNative { static get platform() { if (undefined === nativePlatform) { throw new Error("IModelHost.startup must be called first"); } return nativePlatform; } } /** @internal Strictly to be called by IModelHost.startup. */ export function loadNativePlatform() { if (undefined === nativePlatform) { nativePlatform = ProcessDetector.isMobileAppBackend ? process._linkedBinding("iModelJsNative") : NativeLibrary.load(); nativePlatform.logger = Logger; Logger.onLogLevelChanged.addListener(() => syncNativeLogLevels()); } } /** @internal Strictly for tests. */ export function overrideSyncNativeLogLevels(func) { syncNativeLogLevelsOverride = func; } //# sourceMappingURL=NativePlatform.js.map