UNPKG

4.17 kBTypeScriptView Raw
1/**
2 * Schema for defining an emoji
3 */
4interface Emoji {
5 /** alternative names for this emoji */
6 aliases?: string[];
7 /** keywords to match when searching for emoji */
8 keywords?: string[];
9 /** common ascii representations for this emoji */
10 ascii?: string[];
11 /**
12 * **`images` mode** image file name [`grinning-face.png`]
13 */
14 image?: string;
15 /**
16 * **`sprite` mode** CSS `background-position`
17 */
18 backgroundPosition?: string;
19 /** unicode text character */
20 character: string;
21 /**
22 * categories this emoji fits in (default: `['other']`)
23 *
24 * known categories:
25 * `'people'`,
26 * `'nature'`,
27 * `'food'`,
28 * `'activity'`,
29 * `'travel'`,
30 * `'objects'`,
31 * `'symbols'`,
32 * `'flags'`,
33 * `'regional'`,
34 * `'modifier'`,
35 * `'other'`
36 *
37 * if adding other categories, add translations for them like
38 * `"categories.people": "People"` under `emoji.json`
39 */
40 categories?: string[];
41}
42
43interface EmojiDefinition {
44 /**
45 * human-friendly name of this emoji pack
46 */
47 name: string;
48
49 /**
50 * The ID of this emoji pack.
51 * Used in the CSS classname, etc
52 */
53 id: string;
54
55 /**
56 * The absolute base path of the emoji pack. Other paths are relative to this one
57 * Usually `__dirname` works well for this
58 */
59 path: string;
60
61 /**
62 * Legal attribution for using these emoji, if applicable
63 */
64 attribution?: string;
65
66 /**
67 * License for these emoji
68 */
69 license?: string;
70
71 /**
72 * The mode of this emoji pack.
73 * `images` for individual image files.
74 * `sprite` for a single image sprite file.
75 * `font` for an emoji font.
76 */
77 mode: 'images' | 'sprite' | 'font';
78
79 /**
80 * **`images` mode** options
81 */
82 images?: {
83 /** Path to the directory where the image files are located */
84 directory: string;
85 };
86 /**
87 * **`sprite` mode** options
88 */
89 sprite?: {
90 /** Path to the sprite image file */
91 file: string;
92 /** CSS `background-size` */
93 backgroundSize: string;
94 };
95 /**
96 * **`font` mode** options
97 */
98 font?: {
99 /** Path to the emoji font `.eot` file (for old IE support) */
100 eot?: string;
101 /** Path to the emoji font `.ttf` file */
102 ttf?: string;
103 /** Path to the emoji font `.woff` file */
104 woff?: string;
105 /** Path to the emoji font `.woff2` file */
106 woff2?: string;
107 /** Path to the emoji font `.svg` file
108 * (for Apple support, end this with the `#fontname` convention) */
109 svg?: string;
110
111 /** CSS `font-family` name */
112 family: string;
113 };
114
115 /**
116 * A map of emoji names to one of the following
117 */
118 dictionary: {
119 [name: string]: Emoji;
120 };
121}
122
123declare type NodeBack<T = any> = (err?: Error, ...args: T[]) => void;
124
125interface StoredEmoji {
126 name: string;
127 character: string;
128 image: string;
129 pack: string;
130 aliases: string[];
131 keywords: string[];
132}
133
134declare namespace MetaData {
135 /** table of all emoji */
136 interface Table {
137 [name: string]: StoredEmoji;
138 }
139
140 /** map of all aliases to the base name */
141 interface Aliases {
142 [alias: string]: string;
143 }
144
145 /** map of ascii to base names */
146 interface Ascii {
147 [str: string]: string;
148 }
149
150 /** list of emoji names in each category */
151 interface Categories {
152 [category: string]: string[];
153 }
154
155 /** map of characters to emoji names */
156 interface Characters {
157 [character: string]: string;
158 }
159
160 /** storing pack information for dialog */
161 type Packs = {
162 name: string;
163 id: string;
164 attribution: string;
165 license: string;
166 }[];
167}
168
169declare namespace NodeJS {
170 export interface Global {
171 env: 'development' | 'production';
172 }
173}
174
175interface CustomEmoji {
176 /** name of custom emoji */
177 name: string;
178 /** custom image for emoji */
179 image: string;
180 aliases: string[];
181 ascii: string[];
182}
183
184interface CustomAdjunct {
185 /** Name of original emoji */
186 name: string;
187 /** Additional aliases for the emoji */
188 aliases: string[];
189 /** Additional ascii patterns for this emoji */
190 ascii: string[];
191}
192
193interface Customizations {
194 emojis: CustomEmoji[];
195 adjuncts: CustomAdjunct[];
196}
197
198declare module 'string-hash' {
199 const hash: (str: string) => number;
200 export = hash;
201}