import { AutoEnvAttributes, Context, internal, LDFlagSet, LDFlagValue, LDLogger, LDPluginEnvironmentMetadata, Platform } from '@launchdarkly/js-sdk-common'; import { Hook, LDClient, LDClientIdentifyResult, LDContext, LDContextStrict, LDIdentifyResult, type LDOptions, LDWaitForInitializationOptions, LDWaitForInitializationResult } from './api'; import { LDEvaluationDetail, LDEvaluationDetailTyped } from './api/LDEvaluationDetail'; import { LDIdentifyOptions } from './api/LDIdentifyOptions'; import { LDClientInternalOptions } from './configuration'; import { DataManager, DataManagerFactory } from './DataManager'; import { LDDebugOverride } from './flag-manager/FlagManager'; import { ItemDescriptor } from './flag-manager/ItemDescriptor'; import LDEmitter, { EventName } from './LDEmitter'; export default class LDClientImpl implements LDClient, LDClientIdentifyResult { readonly sdkKey: string; readonly autoEnvAttributes: AutoEnvAttributes; readonly platform: Platform; private readonly _config; private readonly _diagnosticsManager?; private _eventProcessor?; readonly logger: LDLogger; private _activeContextTracker; private readonly _highTimeoutThreshold; private _eventFactoryDefault; private _eventFactoryWithReasons; protected emitter: LDEmitter; private _flagManager; private _eventSendingEnabled; private _baseHeaders; protected dataManager: DataManager; protected readonly environmentMetadata: LDPluginEnvironmentMetadata; private _hookRunner; private _inspectorManager; private _identifyQueue; protected initializedPromise?: Promise; protected initResolve?: (result: LDWaitForInitializationResult) => void; protected initializeResult?: LDWaitForInitializationResult; /** * Creates the client object synchronously. No async, no network calls. */ constructor(sdkKey: string, autoEnvAttributes: AutoEnvAttributes, platform: Platform, options: LDOptions, dataManagerFactory: DataManagerFactory, internalOptions?: LDClientInternalOptions); allFlags(): LDFlagSet; close(): Promise; flush(): Promise<{ error?: Error; result: boolean; }>; getContext(): LDContextStrict | undefined; protected getInternalContext(): Context | undefined; /** * Preset flags are used to set the flags before the client is initialized. This is useful for * when client has precached flags that are ready to evaluate without full initialization. * @param newFlags - The flags to preset. */ protected presetFlags(newFlags: { [key: string]: ItemDescriptor; }): void; /** * Identifies a context to LaunchDarkly. See {@link LDClient.identify}. * * If used with the `sheddable` option set to true, then the identify operation will be sheddable. This means that if * multiple identify operations are done, without waiting for the previous one to complete, then intermediate * operations may be discarded. * * It is recommended to use the `identifyResult` method instead when the operation is sheddable. In a future release, * all identify operations will default to being sheddable. * * @param pristineContext The LDContext object to be identified. * @param identifyOptions Optional configuration. See {@link LDIdentifyOptions}. * @returns A Promise which resolves when the flag values for the specified * context are available. It rejects when: * * 1. The context is unspecified or has no key. * * 2. The identify timeout is exceeded. In client SDKs this defaults to 5s. * You can customize this timeout with {@link LDIdentifyOptions | identifyOptions}. * * 3. A network error is encountered during initialization. */ identify(pristineContext: LDContext, identifyOptions?: LDIdentifyOptions): Promise; identifyResult(pristineContext: LDContext, identifyOptions?: LDIdentifyOptions): Promise; /** * Sets the initialization result and resolves any pending waitForInitialization promises. * This method is idempotent and will only be set by the initialization flow. Subsequent calls * should not do anything. * @param result The initialization result. */ protected maybeSetInitializationResult(result: LDWaitForInitializationResult): void; waitForInitialization(options?: LDWaitForInitializationOptions): Promise; /** * Apply a timeout promise to a base promise. This is for use with waitForInitialization. * * @param basePromise The promise to race against a timeout. * @param timeout The timeout in seconds. * @returns A promise that resolves to the initialization result or timeout. * * @privateRemarks * This method is protected because it is used by the browser SDK's `start` method. * Eventually, the start method will be moved to this common implementation and this method will * be made private. */ protected promiseWithTimeout(basePromise: Promise, timeout: number): Promise; on(eventName: EventName, listener: Function): void; off(eventName: EventName, listener: Function): void; track(key: string, data?: any, metricValue?: number): void; private _variationInternal; variation(flagKey: string, defaultValue?: LDFlagValue): LDFlagValue; variationDetail(flagKey: string, defaultValue?: LDFlagValue): LDEvaluationDetail; private _typedEval; boolVariation(key: string, defaultValue: boolean): boolean; jsonVariation(key: string, defaultValue: unknown): unknown; numberVariation(key: string, defaultValue: number): number; stringVariation(key: string, defaultValue: string): string; boolVariationDetail(key: string, defaultValue: boolean): LDEvaluationDetailTyped; numberVariationDetail(key: string, defaultValue: number): LDEvaluationDetailTyped; stringVariationDetail(key: string, defaultValue: string): LDEvaluationDetailTyped; jsonVariationDetail(key: string, defaultValue: unknown): LDEvaluationDetailTyped; addHook(hook: Hook): void; /** * Enable/Disable event sending. * @param enabled True to enable event processing, false to disable. * @param flush True to flush while disabling. Useful to flush on certain state transitions. */ protected setEventSendingEnabled(enabled: boolean, flush: boolean): void; protected sendEvent(event: internal.InputEvent): void; protected getDebugOverrides(): LDDebugOverride | undefined; private _handleInspectionChanged; } //# sourceMappingURL=LDClientImpl.d.ts.map