import { ContextTransformFieldType, ContextType, CurrencyType, DateFieldType, DayPeriodType, KeyIndexMap, PluralType, Schema, UnitInfo, UnitType } from '@phensley/cldr-types'; import { SchemaConfig } from '../schema'; import { Decimal, DecimalArg, Part } from '@phensley/decimal'; import { CurrencyFormatOptions, CurrencySymbolWidthType, DecimalAdjustOptions, DecimalFormatOptions, ListPatternType, Quantity, RelativeTimeFormatOptions, UnitFormatOptions } from '../common'; import { CalendarDate, CalendarType } from '../systems/calendars'; import { ContextTransformInfo, NumberParams } from '../common/private'; import { DateTimeNode } from '../parsing/date'; import { NumberPattern } from '../parsing/number'; import { WrapperNode } from '../parsing/wrapper'; import { Bundle } from '../resource'; import { CalendarContext, CalendarFormatter } from './calendars/formatter'; import { AbstractValue } from '../utils/render'; /** * @internal */ export interface CalendarInternals { getCalendarFormatter(type: CalendarType): CalendarFormatter; flexDayPeriod(bundle: Bundle, minutes: number): DayPeriodType | undefined; parseDatePattern(raw: string): DateTimeNode[]; getHourPattern(raw: string, negative: boolean): DateTimeNode[]; weekFirstDay(region: string): number; weekMinDays(region: string): number; selectCalendar(bundle: Bundle, ca?: CalendarType): CalendarType; formatDateTime(calendar: CalendarType, ctx: CalendarContext, value: AbstractValue, first: boolean, date?: DateTimeNode[], time?: DateTimeNode[], wrapper?: string): R; formatInterval(calendar: CalendarType, ctx: CalendarContext, value: AbstractValue, first: boolean, end: CalendarDate, pattern: DateTimeNode[]): R; } /** * @internal */ export interface DateFieldInternals { formatRelativeTimeField(bundle: Bundle, value: DecimalArg, field: DateFieldType, options: RelativeTimeFormatOptions, params: NumberParams, transform: ContextTransformInfo): string; } /** * @internal */ export interface GeneralInternals { characterOrder(bundle: Bundle): string; lineOrder(bundle: Bundle): string; contextTransform(value: string, info: ContextTransformInfo, context?: ContextType, field?: ContextTransformFieldType): string; formatList(bundle: Bundle, items: string[], type: ListPatternType): string; formatListToParts(bundle: Bundle, items: string[], type: ListPatternType): Part[]; formatListImpl(bundle: Bundle, value: AbstractValue, items: R[], type: ListPatternType): R; formatWrapper(format: string, args: string[]): string; parseWrapper(raw: string): WrapperNode[]; } /** * @internal */ export interface NumberInternals { adjustDecimal(num: DecimalArg, options?: DecimalAdjustOptions): Decimal; stringRenderer(params: NumberParams): NumberRenderer; partsRenderer(params: NumberParams): NumberRenderer; formatDecimal(bundle: Bundle, renderer: NumberRenderer, n: Decimal, options: DecimalFormatOptions, params: NumberParams): [T, PluralType]; formatCurrency(bundle: Bundle, renderer: NumberRenderer, n: Decimal, code: string, options: CurrencyFormatOptions, params: NumberParams): T; getCurrencySymbol(bundle: Bundle, code: CurrencyType, width?: CurrencySymbolWidthType): string; getCurrencyDisplayName(bundle: Bundle, code: CurrencyType): string; getCurrencyPluralName(bundle: Bundle, code: string, plural: PluralType): string; getNumberPattern(raw: string, negative: boolean): NumberPattern; } /** * @internal */ export interface UnitInternals { getDisplayName(bundle: Bundle, name: UnitType, length: string): string; getUnitInfo(length: string): UnitInfo; format(bundle: Bundle, renderer: NumberRenderer, q: Quantity, options: UnitFormatOptions, params: NumberParams): T; } /** * @internal */ export interface NumberRenderer { empty(): R; make(type: string, value: string): R; render(n: Decimal, pattern: NumberPattern, currencySymbol: string, percentSymbol: string, decimalSymbol: string, minInt: number, grouping?: boolean, exponent?: number): R; wrap(internal: GeneralInternals, raw: string, ...args: R[]): R; } /** * Unified interface for accessing internal functionality. * * @internal */ export interface Internals { readonly config: SchemaConfig; readonly indices: KeyIndexMap; readonly checksum: string; readonly calendars: CalendarInternals; readonly dateFields: DateFieldInternals; readonly general: GeneralInternals; readonly numbers: NumberInternals; readonly schema: Schema; readonly units: UnitInternals; }