UNPKG

@jargon/platform-sdk-core

Version:

Core components of the Jargon Platform SDK for node.js

62 lines (61 loc) 4.11 kB
import { IntlMessageFormat, PrimitiveType } from 'intl-messageformat'; import { RenderItem, RenderOptions, RenderParams, ResourceManager, ResourceManagerOptions, SelectedVariation, TypedRenderItem, RenderResult } from '.'; import { LocaleContentV1, ObjectContent, Platform, ResponseContent, ResponseVariant, StringContent, StringResource, VariadicContent, Variant } from './defs'; import { CrossReference } from './references'; declare type IMFParams = Record<string, PrimitiveType>; interface Substitution { param: string; ref: CrossReference; } interface CachedStringResource { readonly format: IntlMessageFormat; readonly subs: Substitution[]; } export declare class LocaleData { readonly locale: string; protected readonly _dataPath: string; protected _contentPromise?: Promise<LocaleContentV1>; protected _cache: Map<string, CachedStringResource>; constructor(locale: string, _dataPath: string); loadContent(): void; content(): Promise<LocaleContentV1>; cachedStringResource(ck: string, msg: string): CachedStringResource; protected _doLoadContent(): Promise<LocaleContentV1>; protected _buildCacheEntry(msg: string): CachedStringResource; } export declare class JargonResourceManager implements ResourceManager { protected readonly _opts: Required<ResourceManagerOptions>; protected readonly _platform: Platform; protected readonly _data: LocaleData; protected readonly _fallbacks: JargonResourceManager[]; readonly locale: string; protected readonly _rv: number; protected _selectedVariants: SelectedVariation[]; constructor(_opts: Required<ResourceManagerOptions>, _platform: Platform, _data: LocaleData, _fallbacks: JargonResourceManager[]); render(item: RenderItem): Promise<string>; renderBatch(items: RenderItem[]): Promise<string[]>; renderObject<T extends object>(item: RenderItem): Promise<T>; renderResponse(item: RenderItem): Promise<ResponseVariant>; renderAll(items: TypedRenderItem[]): Promise<RenderResult[]>; protected _loadObjectContent(key: string): Promise<ObjectContent>; protected _tryLoadObjectContent(key: string): Promise<ObjectContent | undefined>; protected _loadResponseContent(key: string): Promise<ResponseContent>; protected _tryLoadResponseContent(key: string): Promise<ResponseContent | undefined>; protected _loadStringContent(key: string): Promise<StringContent>; protected _tryLoadStringContent(key: string): Promise<StringContent | undefined>; protected _renderString(key: string, params: IMFParams, opts?: RenderOptions): Promise<string>; protected _renderStringVariant(key: string, variant: string, params: IMFParams, opts?: RenderOptions): Promise<string>; protected _renderStringContent(key: string, variant: string, content: string, params: IMFParams, opts?: RenderOptions): Promise<string>; protected _renderResponseComponent(key: string, variant: string, component: string, params: IMFParams, opts?: RenderOptions): Promise<string>; protected _renderCachedStringResource(ck: string, content: string, params: IMFParams, opts?: RenderOptions): Promise<string>; protected _renderCacheEntry(csr: CachedStringResource, params: IMFParams, opts?: RenderOptions): Promise<string>; protected _renderCrossReference(s: Substitution, params: IMFParams, opts?: RenderOptions): Promise<string>; protected _renderStringResource(ck: string, params: IMFParams, resource: StringResource, opts?: RenderOptions): Promise<StringResource>; protected _renderObjectResource(key: string, variant: string, path: string[], params: Record<string, PrimitiveType>, obj: object, opts?: RenderOptions): Promise<object>; protected _selectVariant<T extends Variant>(vc: VariadicContent<T>, opts?: RenderOptions): string; selectedVariation(item: RenderItem): Promise<SelectedVariation>; selectedVariations(): Promise<SelectedVariation[]>; protected _convertParams(params?: RenderParams): Promise<Record<string, PrimitiveType>>; protected _selectKey(keys: string[], opts?: RenderOptions): string; } export {};