forked from tw-in-js/twind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
128 lines (106 loc) · 3.04 KB
/
Copy pathtypes.ts
File metadata and controls
128 lines (106 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import type { BaseTheme, ExtractUserTheme, ThemeFunction, TwindConfig } from '@twind/core'
import type { Numberify, RGBA } from '@ctrl/tinycolor'
export type LanguageId =
| (
| 'html'
| 'javascript'
| 'javascriptreact'
| 'markdown'
| 'svelte'
| 'typescript'
| 'typescriptreact'
| 'vue-html'
| 'vue'
)
// eslint-disable-next-line @typescript-eslint/ban-types
| (string & {})
export interface Intellisense<Theme extends BaseTheme = BaseTheme> {
readonly theme: ThemeFunction<ExtractUserTheme<Theme>>
readonly config: TwindConfig<Theme>
suggest(input: string, options?: SuggestAtOptions): Promise<Suggestion[]>
suggestAt(content: string, offset: number, language: LanguageId): Promise<SuggestionAt | null>
documentationFor(token: string, options?: DocumentationForOptions): Promise<string | null>
documentationAt(
content: string,
offset: number,
language: LanguageId,
): Promise<DocumentationAt | null>
collectColors(content: string, language: LanguageId): Promise<ColorInformation[]>
validate(content: string, language: LanguageId): Promise<Diagnostics[]>
enumerate(): IterableIterator<Suggestion>
}
export interface DocumentationForOptions {
format?: 'md' | 'html'
}
export interface Diagnostics {
code: 'invalidVariant' | 'invalidClass' | 'invalidCSS'
severity: 'hint' | 'info' | 'warning' | 'error'
value: string
message: string
start: number
end: number
suggestions?: []
related?: RelatedDiagnostic[]
}
export interface RelatedDiagnostic {
resource: string
message: string
start: number
end: number
}
export interface DocumentationAt {
start: number
end: number
value: string
}
export interface ColorInformation {
start: number
end: number
value: string
rgba: Numberify<RGBA>
editable?: boolean
}
export interface SuggestAtOptions {
prefix?: string
ignore?: string[]
}
export interface SuggestionAt {
start: number
end: number
suggestions: Suggestion[]
}
export interface SuggestionCommon {
/** The full name of the suggested value */
name: string
/** The value as it will be used in this context */
value: string
/** Short info to be displayed inline */
description?: string
detail?: string
color?: string
}
export interface SuggestionVariant extends SuggestionCommon {
type: 'variant'
}
export interface SuggestionClass extends SuggestionCommon {
type: 'class'
}
export type Suggestion = SuggestionClass | SuggestionVariant
export interface IntellisenseOptions {
cache?: {
/**
The maximum number of milliseconds an item should remain in the cache.
@default Infinity
By default, `maxAge` will be `Infinity`, which means that items will never expire.
Lazy expiration upon the next write or read call.
Individual expiration of an item can be specified by the `set(key, value, maxAge)` method.
*/
readonly maxAge?: number
/**
The maximum number of items before evicting the least recently used items.
@default 1000
*/
readonly maxSize: number
}
mdnOrigin?: string
}