1 | export declare enum TYPE {
|
2 | |
3 |
|
4 |
|
5 | literal = 0,
|
6 | |
7 |
|
8 |
|
9 | argument = 1,
|
10 | |
11 |
|
12 |
|
13 | number = 2,
|
14 | |
15 |
|
16 |
|
17 | date = 3,
|
18 | |
19 |
|
20 |
|
21 | time = 4,
|
22 | |
23 |
|
24 |
|
25 | select = 5,
|
26 | |
27 |
|
28 |
|
29 | plural = 6
|
30 | }
|
31 | export declare const enum SKELETON_TYPE {
|
32 | number = 0,
|
33 | dateTime = 1
|
34 | }
|
35 | export interface LocationDetails {
|
36 | offset: number;
|
37 | line: number;
|
38 | column: number;
|
39 | }
|
40 | export interface Location {
|
41 | start: LocationDetails;
|
42 | end: LocationDetails;
|
43 | }
|
44 | export interface BaseElement<T extends TYPE> {
|
45 | type: T;
|
46 | value: string;
|
47 | location?: Location;
|
48 | }
|
49 | export declare type LiteralElement = BaseElement<TYPE.literal>;
|
50 | export declare type ArgumentElement = BaseElement<TYPE.argument>;
|
51 | export interface SimpleFormatElement<T extends TYPE, S extends Skeleton> extends BaseElement<T> {
|
52 | style?: string | S | null;
|
53 | }
|
54 | export declare type NumberElement = SimpleFormatElement<TYPE.number, NumberSkeleton>;
|
55 | export declare type DateElement = SimpleFormatElement<TYPE.date, DateTimeSkeleton>;
|
56 | export declare type TimeElement = SimpleFormatElement<TYPE.time, DateTimeSkeleton>;
|
57 | export interface SelectOption {
|
58 | id: string;
|
59 | value: MessageFormatElement[];
|
60 | location?: Location;
|
61 | }
|
62 | export declare type ValidPluralRule = 'zero' | 'one' | 'two' | 'few' | 'many' | 'other' | string;
|
63 | export interface PluralOrSelectOption {
|
64 | value: MessageFormatElement[];
|
65 | location?: Location;
|
66 | }
|
67 | export interface SelectElement extends BaseElement<TYPE.select> {
|
68 | options: Record<string, PluralOrSelectOption>;
|
69 | }
|
70 | export interface PluralElement extends BaseElement<TYPE.plural> {
|
71 | options: Record<ValidPluralRule, PluralOrSelectOption>;
|
72 | offset: number;
|
73 | pluralType: Intl.PluralRulesOptions['type'];
|
74 | }
|
75 | export declare type MessageFormatElement = LiteralElement | ArgumentElement | NumberElement | DateElement | TimeElement | SelectElement | PluralElement;
|
76 | export interface NumberSkeletonToken {
|
77 | stem: string;
|
78 | options: string[];
|
79 | }
|
80 | export interface NumberSkeleton {
|
81 | type: SKELETON_TYPE.number;
|
82 | tokens: NumberSkeletonToken[];
|
83 | location?: Location;
|
84 | }
|
85 | export interface DateTimeSkeleton {
|
86 | type: SKELETON_TYPE.dateTime;
|
87 | pattern: string;
|
88 | location?: Location;
|
89 | }
|
90 | export declare type Skeleton = NumberSkeleton | DateTimeSkeleton;
|
91 |
|
92 |
|
93 |
|
94 | export declare function isLiteralElement(el: MessageFormatElement): el is LiteralElement;
|
95 | export declare function isArgumentElement(el: MessageFormatElement): el is ArgumentElement;
|
96 | export declare function isNumberElement(el: MessageFormatElement): el is NumberElement;
|
97 | export declare function isDateElement(el: MessageFormatElement): el is DateElement;
|
98 | export declare function isTimeElement(el: MessageFormatElement): el is TimeElement;
|
99 | export declare function isSelectElement(el: MessageFormatElement): el is SelectElement;
|
100 | export declare function isPluralElement(el: MessageFormatElement): el is PluralElement;
|
101 | export declare function isNumberSkeleton(el: NumberElement['style']): el is NumberSkeleton;
|
102 | export declare function isDateTimeSkeleton(el?: DateElement['style'] | TimeElement['style']): el is DateTimeSkeleton;
|
103 | export declare function createLiteralElement(value: string): LiteralElement;
|
104 | export declare function createNumberElement(value: string, style?: string | null): NumberElement;
|
105 | export interface Options {
|
106 | |
107 |
|
108 |
|
109 |
|
110 |
|
111 | normalizeHashtagInPlural?: boolean;
|
112 | |
113 |
|
114 |
|
115 |
|
116 | captureLocation?: boolean;
|
117 | }
|