import { OdsConfig } from './ods-config'; import { OdsI18nHook } from '../i18n/ods-i18n-hook'; import { OdsExternalLogger } from '../logger/ods-external-logger'; /** * Main class that controls ODS : * - manage / create this singleton * - fire an event once created * - managing logging: enable or not * - managing i18n: in order to connect a translation system * * @example enable log on `ODS` initialization via javascript. make sure to execute this before any `ODS` script. * ```html * * ``` * * @example enable log on `ODS` initialization via typescript. make sure to execute this before any `ODS` script. * ```typescript * import { * OdsInitializedEvent, * OdsInitializedEventName * } from '@ovhcloud/ods-core'; * * document.addEventListener(OdsInitializedEventName, (event) => { * const evt = event as OdsInitializedEvent; * const instance = evt.detail.instance; * instance.logging(true); * const logger = new instance.logger('MY CONTEXT'); * logger.log('odsInitialized received'); * }) * ``` * * @example enable log on demand via typescript * ```typescript * import { Ods } from '@ovhcloud/ods-core'; * Ods.instance().logging(true); * ``` * * @example configure different element of `ODS` * ```typescript * import { Ods } from '@ovhcloud/ods-core'; * const my translationCbk: OdsI18nHook = (key, values) => `${key} to be translated`; * Ods.instance() * .logging(true) * .i18n(translationCbk); * ``` * * @example use the embedded logger of `ODS` via typescript * ```typescript * import { Ods } from '@ovhcloud/ods-core'; * * Ods.instance().logging(true); * const myLogger = new (Ods.instance().logger)('MY CONTEXT'); * * myLogger.log('my log with the same logger as ODS'); * myLogger.error('my error log with the same logger as ODS'); * * Ods.instance().logging(false); * myLogger.log('my log is disabled as ods log is disabled'); * ``` * */ export declare class Ods { private readonly config; private static _instance; private static _instanceId; private readonly instanceId; version: string; private genericLogger; private i18nHook?; constructor(config: OdsConfig); /** * @deprecated use `Ods.instance()` */ static configure(): Ods; /** * get or create the ODS instance. * The singleton is retrieved if exist */ static instance(config?: OdsConfig): Ods; /** * set your custom i18n callback function that is processing translations. * the callback has to return the translated string processed by your translation system. * @param hook - function that will receive the values to translate */ i18n(hook: OdsI18nHook): Ods; getI18n(): OdsI18nHook | undefined; /** * set the default asset path where to find the different assets of `ODS`. * @param path - path like `my-ods-svg/` */ assetPath(path: string): Ods; /** * get all the configuration of `ODS` */ getConfig(): OdsConfig; /** * enable or not the logging for the `ODS` instance * @param enable - your boolean */ logging(enable: boolean): Ods; isLoggingActive(): boolean; get logger(): typeof OdsExternalLogger; }