-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathtypes.d.ts
120 lines (113 loc) · 2.9 KB
/
types.d.ts
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
/**
* Get a URL to the oniguruma WASM.
*
* > **Note**: this must currently result in a version 2 URL of
* > `onig.wasm` from `vscode-oniguruma`.
*
* > **Danger**: when you use this functionality, your project might break at
* > any time (when reinstalling dependencies), except when you make sure that
* > the WASM binary you load manually is what our internally used
* > `vscode-oniguruma` dependency expects.
* > To solve this, you could for example use an npm script called `dependencies`
* > (which runs everytime `node_modules` is changed) which copies
* > `vscode-oniguruma/release/onig.wasm` to the place you want to host it.
*
* @returns
* URL object to a WASM binary.
* @example
* ```js
* import {common, createStarryNight} from '@wooorm/starry-night'
*
* const starryNight = await createStarryNight(common, {
* getOnigurumaUrlFetch() {
* return new URL('/onig.wasm', window.location.href);
* }
* })
* ```
*/
export type GetOnigurumaUrl = () => Promise<Readonly<URL>> | Readonly<URL>
/**
* TextMate grammar with some extra info.
*/
export interface Grammar {
/**
* List of scopes that are needed for this grammar to work (optional,
* example: `['source.tsx']`).
*/
dependencies?: Array<string>
/**
* List of extensions (example: `['.mdx']`).
*/
extensions: Array<string>
/**
* List of extensions that only match if used w/ a dot (optional, example:
* `['.php']`).
*/
extensionsWithDot?: Array<string>
/**
* TextMate injections (optional).
*/
injections?: Record<string, Rule>
/**
* List of names (example: `['mdx']`).
*/
names: Array<string>
/**
* TextMate patterns.
*/
patterns: Array<Rule>
/**
* TextMate repository (optional).
*/
repository?: Record<string, Rule>
/**
* Scope (example: `source.mdx`).
*/
scopeName: string
}
/**
* Configuration (optional).
*/
export interface Options {
/**
* Get a URL to the oniguruma WASM, typically used in browsers (optional).
*/
getOnigurumaUrlFetch?: GetOnigurumaUrl | null | undefined
/**
* Get a URL to the oniguruma WASM, typically used in Node.js (optional).
*/
getOnigurumaUrlFs?: GetOnigurumaUrl | null | undefined
}
/**
* TextMate rule.
*/
export type Rule = RuleDefinition | RuleInclude | RuleName
export interface RuleDefinition {
applyEndPatternLast?: boolean
begin?: string
beginCaptures?: Record<string, Rule>
captures?: Record<string, Rule>
contentName?: string
end?: string
endCaptures?: Record<string, Rule>
injections?: Record<string, Rule>
match?: string
name?: string
patterns?: Array<Rule>
repository?: Record<string, Rule>
while?: string
whileCaptures?: Record<string, Rule>
}
export interface RuleInclude {
begin?: string
end?: string
include: string
match?: string
name?: string
}
export interface RuleName {
begin?: never
include?: never
match?: never
name: string
}