|
1 |
| -// @flow |
2 |
| - |
3 |
| -import type { Key } from "react"; |
4 |
| -import includedLangs from "./vendor/prism/includeLangs"; |
5 |
| - |
6 |
| -export type Language = $Keys<typeof includedLangs>; |
7 |
| - |
8 |
| -type PrismGrammar = { |
9 |
| - [key: string]: mixed |
10 |
| -}; |
11 |
| - |
12 |
| -type LanguagesDict = { |
13 |
| - [lang: Language]: PrismGrammar |
14 |
| -}; |
15 |
| - |
16 |
| -export type PrismToken = { |
17 |
| - type: string | string[], |
18 |
| - alias: string | string[], |
19 |
| - content: Array<PrismToken | string> | string |
20 |
| -}; |
21 |
| - |
22 |
| -export type Token = { |
23 |
| - types: string[], |
24 |
| - content: string, |
25 |
| - empty?: boolean |
26 |
| -}; |
27 |
| - |
28 |
| -export type PrismLib = { |
29 |
| - languages: LanguagesDict, |
30 |
| - tokenize: ( |
31 |
| - code: string, |
32 |
| - grammar: PrismGrammar, |
33 |
| - language: Language |
34 |
| - ) => Array<PrismToken | string>, |
35 |
| - highlight: (code: string, grammar: PrismGrammar, language: Language) => string |
36 |
| -}; |
37 |
| - |
38 |
| -export type StyleObj = { |
39 |
| - [key: string]: string | number | null |
40 |
| -}; |
41 |
| - |
42 |
| -export type LineInputProps = { |
43 |
| - key?: Key, |
44 |
| - style?: StyleObj, |
45 |
| - className?: string, |
46 |
| - line: Token[], |
47 |
| - [key: string]: mixed |
48 |
| -}; |
49 |
| - |
50 |
| -export type LineOutputProps = { |
51 |
| - key?: Key, |
52 |
| - style?: StyleObj, |
53 |
| - className: string, |
54 |
| - [key: string]: mixed |
55 |
| -}; |
56 |
| - |
57 |
| -export type TokenInputProps = { |
58 |
| - key?: Key, |
59 |
| - style?: StyleObj, |
60 |
| - className?: string, |
61 |
| - token: Token, |
62 |
| - [key: string]: mixed |
63 |
| -}; |
64 |
| - |
65 |
| -export type TokenOutputProps = { |
66 |
| - key?: Key, |
67 |
| - style?: StyleObj, |
68 |
| - className: string, |
69 |
| - children: string, |
70 |
| - [key: string]: mixed |
71 |
| -}; |
72 |
| - |
73 |
| -export type RenderProps = { |
74 |
| - tokens: Token[][], |
75 |
| - className: string, |
76 |
| - getLineProps: (input: LineInputProps) => LineOutputProps, |
77 |
| - getTokenProps: (input: TokenInputProps) => TokenOutputProps |
78 |
| -}; |
79 |
| - |
80 |
| -export type PrismThemeEntry = { |
81 |
| - color?: string, |
82 |
| - backgroundColor?: string, |
83 |
| - fontStyle?: "normal" | "italic", |
84 |
| - fontWeight?: |
85 |
| - | "normal" |
86 |
| - | "bold" |
87 |
| - | "100" |
88 |
| - | "200" |
89 |
| - | "300" |
90 |
| - | "400" |
91 |
| - | "500" |
92 |
| - | "600" |
93 |
| - | "700" |
94 |
| - | "800" |
95 |
| - | "900", |
96 |
| - textDecorationLine?: |
97 |
| - | "none" |
98 |
| - | "underline" |
99 |
| - | "line-through" |
100 |
| - | "underline line-through", |
101 |
| - opacity?: number, |
102 |
| - [styleKey: string]: string | number | void |
103 |
| -}; |
104 |
| - |
105 |
| -export type PrismTheme = { |
106 |
| - plain: PrismThemeEntry, |
107 |
| - styles: Array<{ |
108 |
| - types: string[], |
109 |
| - style: PrismThemeEntry, |
110 |
| - languages?: Language[] |
111 |
| - }> |
112 |
| -}; |
| 1 | +// @flow |
| 2 | + |
| 3 | +import type { Key } from "react"; |
| 4 | +import includedLangs from "./vendor/prism/includeLangs"; |
| 5 | + |
| 6 | +export type Language = $Keys<typeof includedLangs>; |
| 7 | + |
| 8 | +type PrismGrammar = { |
| 9 | + [key: string]: mixed, |
| 10 | +}; |
| 11 | + |
| 12 | +type LanguagesDict = { |
| 13 | + [lang: Language]: PrismGrammar, |
| 14 | +}; |
| 15 | + |
| 16 | +export type PrismToken = { |
| 17 | + type: string | string[], |
| 18 | + alias: string | string[], |
| 19 | + content: Array<PrismToken | string> | string, |
| 20 | +}; |
| 21 | + |
| 22 | +export type Token = { |
| 23 | + types: string[], |
| 24 | + content: string, |
| 25 | + empty?: boolean, |
| 26 | +}; |
| 27 | + |
| 28 | +export type PrismLib = { |
| 29 | + languages: LanguagesDict, |
| 30 | + tokenize: ( |
| 31 | + code: string, |
| 32 | + grammar: PrismGrammar, |
| 33 | + language: Language |
| 34 | + ) => Array<PrismToken | string>, |
| 35 | + highlight: ( |
| 36 | + code: string, |
| 37 | + grammar: PrismGrammar, |
| 38 | + language: Language |
| 39 | + ) => string, |
| 40 | +}; |
| 41 | + |
| 42 | +export type StyleObj = { |
| 43 | + [key: string]: string | number | null, |
| 44 | +}; |
| 45 | + |
| 46 | +export type LineInputProps = { |
| 47 | + key?: Key, |
| 48 | + style?: StyleObj, |
| 49 | + className?: string, |
| 50 | + line: Token[], |
| 51 | + [key: string]: mixed, |
| 52 | +}; |
| 53 | + |
| 54 | +export type LineOutputProps = { |
| 55 | + key?: Key, |
| 56 | + style?: StyleObj, |
| 57 | + className: string, |
| 58 | + [key: string]: mixed, |
| 59 | +}; |
| 60 | + |
| 61 | +export type TokenInputProps = { |
| 62 | + key?: Key, |
| 63 | + style?: StyleObj, |
| 64 | + className?: string, |
| 65 | + token: Token, |
| 66 | + [key: string]: mixed, |
| 67 | +}; |
| 68 | + |
| 69 | +export type TokenOutputProps = { |
| 70 | + key?: Key, |
| 71 | + style?: StyleObj, |
| 72 | + className: string, |
| 73 | + children: string, |
| 74 | + [key: string]: mixed, |
| 75 | +}; |
| 76 | + |
| 77 | +export type RenderProps = { |
| 78 | + tokens: Token[][], |
| 79 | + className: string, |
| 80 | + getLineProps: (input: LineInputProps) => LineOutputProps, |
| 81 | + getTokenProps: (input: TokenInputProps) => TokenOutputProps, |
| 82 | +}; |
| 83 | + |
| 84 | +export type PrismThemeEntry = { |
| 85 | + color?: string, |
| 86 | + backgroundColor?: string, |
| 87 | + fontStyle?: "normal" | "italic", |
| 88 | + fontWeight?: |
| 89 | + | "normal" |
| 90 | + | "bold" |
| 91 | + | "100" |
| 92 | + | "200" |
| 93 | + | "300" |
| 94 | + | "400" |
| 95 | + | "500" |
| 96 | + | "600" |
| 97 | + | "700" |
| 98 | + | "800" |
| 99 | + | "900", |
| 100 | + textDecorationLine?: |
| 101 | + | "none" |
| 102 | + | "underline" |
| 103 | + | "line-through" |
| 104 | + | "underline line-through", |
| 105 | + opacity?: number, |
| 106 | + [styleKey: string]: string | number | void, |
| 107 | +}; |
| 108 | + |
| 109 | +export type PrismTheme = { |
| 110 | + plain: PrismThemeEntry, |
| 111 | + styles: Array<{ |
| 112 | + types: string[], |
| 113 | + style: PrismThemeEntry, |
| 114 | + languages?: Language[], |
| 115 | + }>, |
| 116 | +}; |
0 commit comments