UNPKG

@itwin/core-backend

Version:
49 lines 1.93 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * 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 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.IModelNative = void 0; exports.loadNativePlatform = loadNativePlatform; exports.overrideSyncNativeLogLevels = overrideSyncNativeLogLevels; const imodeljs_native_1 = require("@bentley/imodeljs-native"); const core_bentley_1 = require("@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 */ class IModelNative { static get platform() { if (undefined === nativePlatform) { throw new Error("IModelHost.startup must be called first"); } return nativePlatform; } } exports.IModelNative = IModelNative; /** @internal Strictly to be called by IModelHost.startup. */ function loadNativePlatform() { if (undefined === nativePlatform) { nativePlatform = core_bentley_1.ProcessDetector.isMobileAppBackend ? process._linkedBinding("iModelJsNative") : imodeljs_native_1.NativeLibrary.load(); nativePlatform.logger = core_bentley_1.Logger; core_bentley_1.Logger.onLogLevelChanged.addListener(() => syncNativeLogLevels()); } } /** @internal Strictly for tests. */ function overrideSyncNativeLogLevels(func) { syncNativeLogLevelsOverride = func; } //# sourceMappingURL=NativePlatform.js.map