@discord/markdown-types 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.d.ts +100 -0
  2. package/package.json +9 -0
package/index.d.ts ADDED
@@ -0,0 +1,100 @@
1
+ export type Node<T, V> = {
2
+ type: T;
3
+ value: V;
4
+ };
5
+
6
+ export type EmptyNode<T> = { type: T; value?: never };
7
+
8
+ export type AnyNode<T = any, V = any> = Node<T, V> | EmptyNode<T>;
9
+
10
+ // base
11
+ export type Text = Node<"text", string>;
12
+ export type Paragraph = Node<"paragraph", Inline[]>;
13
+
14
+ export type Code = Node<"code", string>;
15
+
16
+ export type Spoiler = Node<"spoiler", Inline[]>;
17
+ export type Strikethrough = Node<"strikethrough", Inline[]>;
18
+ export type Underline = Node<"underline", Inline[]>;
19
+ export type Italic = Node<"italic", Inline[]>;
20
+ export type Bold = Node<"bold", Inline[]>;
21
+
22
+ export type NormalLink = Node<
23
+ "normal",
24
+ {
25
+ text?: Exclude<Inline, Link>[];
26
+ url: string;
27
+ title?: string;
28
+ }
29
+ >;
30
+
31
+ export type MentionLink = Node<"mention", any>;
32
+
33
+ export type Link = Node<"link", NormalLink | MentionLink>;
34
+
35
+ export type UserMention = Node<"user", string>;
36
+ export type ChannelMention = Node<"channel", string>;
37
+ export type RoleMention = Node<"role", string>;
38
+ export type CommandMention = Node<"command", { name: string; id: string }>;
39
+ export type EveryoneMention = EmptyNode<"everyone">;
40
+ export type HereMention = EmptyNode<"here">;
41
+ export type Mention = Node<
42
+ "mention",
43
+ | UserMention
44
+ | ChannelMention
45
+ | RoleMention
46
+ | CommandMention
47
+ | EveryoneMention
48
+ | HereMention
49
+ >;
50
+
51
+ export type Timestamp = Node<"timestamp", { value: string; style?: string }>;
52
+
53
+ export type CustomEmoji = Node<
54
+ "custom",
55
+ { animated: boolean; name: string; id: string }
56
+ >;
57
+ export type UnicodeEmoji = Node<"unicode", string>;
58
+ export type Emoji = Node<"emoji", CustomEmoji | UnicodeEmoji>;
59
+
60
+ export type CodeBlock = Node<
61
+ "code_block",
62
+ { language?: string; content: string }
63
+ >;
64
+
65
+ export type Inline =
66
+ | Bold
67
+ | Code
68
+ | CodeBlock
69
+ | Emoji
70
+ | Italic
71
+ | Link
72
+ | Mention
73
+ | Spoiler
74
+ | Strikethrough
75
+ | Timestamp
76
+ | Underline;
77
+
78
+ export type Heading = Node<
79
+ "heading",
80
+ {
81
+ level: number;
82
+ content: Inline[];
83
+ }
84
+ >;
85
+
86
+ export type ListItem = { content: (List | Paragraph)[] };
87
+ export type List = Node<
88
+ "list",
89
+ {
90
+ type: "unordered" | "ordered";
91
+ value?: number;
92
+ items: ListItem[];
93
+ }
94
+ >;
95
+ export type Empty = EmptyNode<"empty">;
96
+ export type QuoteLine = Inline[];
97
+ export type Quote = Node<"quote", { lines: QuoteLine[] }>;
98
+ export type Small = Node<"small", { content: Inline[] }>;
99
+
100
+ export type Block = Heading | List | Quote | Small;
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "@discord/markdown-types",
3
+ "version": "0.1.1",
4
+ "description": "TypeScript types for Discord Markdown AST nodes",
5
+ "types": "index.d.ts",
6
+ "keywords": [],
7
+ "author": "Will Nelson",
8
+ "license": "MIT"
9
+ }