@shikijs/core 1.15.2 → 1.16.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.
- package/dist/chunk-engines.d.mts +29 -1
- package/dist/index.d.mts +117 -78
- package/dist/index.mjs +1009 -922
- package/dist/types.d.mts +665 -5
- package/dist/wasm-inlined.d.mts +1 -0
- package/package.json +3 -2
- package/dist/chunk-tokens.d.mts +0 -1062
- package/dist/textmate.d.mts +0 -3
- package/dist/textmate.mjs +0 -3135
package/dist/chunk-tokens.d.mts
DELETED
|
@@ -1,1062 +0,0 @@
|
|
|
1
|
-
import { Root, Element } from 'hast';
|
|
2
|
-
import { L as LoadWasmOptions } from './chunk-engines.mjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* A union of given const enum values.
|
|
6
|
-
*/
|
|
7
|
-
type OrMask<T extends number> = number;
|
|
8
|
-
|
|
9
|
-
interface IOnigLib {
|
|
10
|
-
createOnigScanner(sources: string[]): OnigScanner;
|
|
11
|
-
createOnigString(str: string): OnigString;
|
|
12
|
-
}
|
|
13
|
-
interface IOnigCaptureIndex {
|
|
14
|
-
start: number;
|
|
15
|
-
end: number;
|
|
16
|
-
length: number;
|
|
17
|
-
}
|
|
18
|
-
interface IOnigMatch {
|
|
19
|
-
index: number;
|
|
20
|
-
captureIndices: IOnigCaptureIndex[];
|
|
21
|
-
}
|
|
22
|
-
declare const enum FindOption {
|
|
23
|
-
None = 0,
|
|
24
|
-
/**
|
|
25
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
|
|
26
|
-
*/
|
|
27
|
-
NotBeginString = 1,
|
|
28
|
-
/**
|
|
29
|
-
* equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
|
|
30
|
-
*/
|
|
31
|
-
NotEndString = 2,
|
|
32
|
-
/**
|
|
33
|
-
* equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
|
|
34
|
-
*/
|
|
35
|
-
NotBeginPosition = 4,
|
|
36
|
-
/**
|
|
37
|
-
* used for debugging purposes.
|
|
38
|
-
*/
|
|
39
|
-
DebugCall = 8
|
|
40
|
-
}
|
|
41
|
-
interface OnigScanner {
|
|
42
|
-
findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
|
|
43
|
-
dispose?(): void;
|
|
44
|
-
}
|
|
45
|
-
interface OnigString {
|
|
46
|
-
readonly content: string;
|
|
47
|
-
dispose?(): void;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
declare const ruleIdSymbol: unique symbol;
|
|
51
|
-
type RuleId = {
|
|
52
|
-
__brand: typeof ruleIdSymbol;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
declare class Theme {
|
|
56
|
-
private readonly _colorMap;
|
|
57
|
-
private readonly _defaults;
|
|
58
|
-
private readonly _root;
|
|
59
|
-
static createFromRawTheme(source: IRawTheme | undefined, colorMap?: string[]): Theme;
|
|
60
|
-
static createFromParsedTheme(source: ParsedThemeRule[], colorMap?: string[]): Theme;
|
|
61
|
-
private readonly _cachedMatchRoot;
|
|
62
|
-
constructor(_colorMap: ColorMap, _defaults: StyleAttributes, _root: ThemeTrieElement);
|
|
63
|
-
getColorMap(): string[];
|
|
64
|
-
getDefaults(): StyleAttributes;
|
|
65
|
-
match(scopePath: ScopeStack | null): StyleAttributes | null;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Identifiers with a binary dot operator.
|
|
69
|
-
* Examples: `baz` or `foo.bar`
|
|
70
|
-
*/
|
|
71
|
-
type ScopeName = string;
|
|
72
|
-
/**
|
|
73
|
-
* An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator.
|
|
74
|
-
* Examples: `foo.bar boo.baz,quick quack`
|
|
75
|
-
*/
|
|
76
|
-
type ScopePattern = string;
|
|
77
|
-
/**
|
|
78
|
-
* A TextMate theme.
|
|
79
|
-
*/
|
|
80
|
-
interface IRawTheme {
|
|
81
|
-
readonly name?: string;
|
|
82
|
-
readonly settings: IRawThemeSetting[];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* A single theme setting.
|
|
86
|
-
*/
|
|
87
|
-
interface IRawThemeSetting {
|
|
88
|
-
readonly name?: string;
|
|
89
|
-
readonly scope?: ScopePattern | ScopePattern[];
|
|
90
|
-
readonly settings: {
|
|
91
|
-
readonly fontStyle?: string;
|
|
92
|
-
readonly foreground?: string;
|
|
93
|
-
readonly background?: string;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
declare class ScopeStack {
|
|
97
|
-
readonly parent: ScopeStack | null;
|
|
98
|
-
readonly scopeName: ScopeName;
|
|
99
|
-
static push(path: ScopeStack | null, scopeNames: ScopeName[]): ScopeStack | null;
|
|
100
|
-
static from(first: ScopeName, ...segments: ScopeName[]): ScopeStack;
|
|
101
|
-
static from(...segments: ScopeName[]): ScopeStack | null;
|
|
102
|
-
constructor(parent: ScopeStack | null, scopeName: ScopeName);
|
|
103
|
-
push(scopeName: ScopeName): ScopeStack;
|
|
104
|
-
getSegments(): ScopeName[];
|
|
105
|
-
toString(): string;
|
|
106
|
-
extends(other: ScopeStack): boolean;
|
|
107
|
-
getExtensionIfDefined(base: ScopeStack | null): string[] | undefined;
|
|
108
|
-
}
|
|
109
|
-
declare class StyleAttributes {
|
|
110
|
-
readonly fontStyle: OrMask<FontStyle$1>;
|
|
111
|
-
readonly foregroundId: number;
|
|
112
|
-
readonly backgroundId: number;
|
|
113
|
-
constructor(fontStyle: OrMask<FontStyle$1>, foregroundId: number, backgroundId: number);
|
|
114
|
-
}
|
|
115
|
-
declare class ParsedThemeRule {
|
|
116
|
-
readonly scope: ScopeName;
|
|
117
|
-
readonly parentScopes: ScopeName[] | null;
|
|
118
|
-
readonly index: number;
|
|
119
|
-
readonly fontStyle: OrMask<FontStyle$1>;
|
|
120
|
-
readonly foreground: string | null;
|
|
121
|
-
readonly background: string | null;
|
|
122
|
-
constructor(scope: ScopeName, parentScopes: ScopeName[] | null, index: number, fontStyle: OrMask<FontStyle$1>, foreground: string | null, background: string | null);
|
|
123
|
-
}
|
|
124
|
-
declare const enum FontStyle$1 {
|
|
125
|
-
NotSet = -1,
|
|
126
|
-
None = 0,
|
|
127
|
-
Italic = 1,
|
|
128
|
-
Bold = 2,
|
|
129
|
-
Underline = 4,
|
|
130
|
-
Strikethrough = 8
|
|
131
|
-
}
|
|
132
|
-
declare class ColorMap {
|
|
133
|
-
private readonly _isFrozen;
|
|
134
|
-
private _lastColorId;
|
|
135
|
-
private _id2color;
|
|
136
|
-
private _color2id;
|
|
137
|
-
constructor(_colorMap?: string[]);
|
|
138
|
-
getId(color: string | null): number;
|
|
139
|
-
getColorMap(): string[];
|
|
140
|
-
}
|
|
141
|
-
declare class ThemeTrieElementRule {
|
|
142
|
-
scopeDepth: number;
|
|
143
|
-
parentScopes: ScopeName[] | null;
|
|
144
|
-
fontStyle: number;
|
|
145
|
-
foreground: number;
|
|
146
|
-
background: number;
|
|
147
|
-
constructor(scopeDepth: number, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number);
|
|
148
|
-
clone(): ThemeTrieElementRule;
|
|
149
|
-
static cloneArr(arr: ThemeTrieElementRule[]): ThemeTrieElementRule[];
|
|
150
|
-
acceptOverwrite(scopeDepth: number, fontStyle: number, foreground: number, background: number): void;
|
|
151
|
-
}
|
|
152
|
-
interface ITrieChildrenMap {
|
|
153
|
-
[segment: string]: ThemeTrieElement;
|
|
154
|
-
}
|
|
155
|
-
declare class ThemeTrieElement {
|
|
156
|
-
private readonly _mainRule;
|
|
157
|
-
private readonly _children;
|
|
158
|
-
private readonly _rulesWithParentScopes;
|
|
159
|
-
constructor(_mainRule: ThemeTrieElementRule, rulesWithParentScopes?: ThemeTrieElementRule[], _children?: ITrieChildrenMap);
|
|
160
|
-
private static _sortBySpecificity;
|
|
161
|
-
private static _cmpBySpecificity;
|
|
162
|
-
match(scope: ScopeName): ThemeTrieElementRule[];
|
|
163
|
-
insert(scopeDepth: number, scope: ScopeName, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number): void;
|
|
164
|
-
private _doInsertHere;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
interface IRawGrammar extends ILocatable {
|
|
168
|
-
repository: IRawRepository;
|
|
169
|
-
readonly scopeName: ScopeName;
|
|
170
|
-
readonly patterns: IRawRule[];
|
|
171
|
-
readonly injections?: {
|
|
172
|
-
[expression: string]: IRawRule;
|
|
173
|
-
};
|
|
174
|
-
readonly injectionSelector?: string;
|
|
175
|
-
readonly fileTypes?: string[];
|
|
176
|
-
readonly name?: string;
|
|
177
|
-
readonly firstLineMatch?: string;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Allowed values:
|
|
181
|
-
* * Scope Name, e.g. `source.ts`
|
|
182
|
-
* * Top level scope reference, e.g. `source.ts#entity.name.class`
|
|
183
|
-
* * Relative scope reference, e.g. `#entity.name.class`
|
|
184
|
-
* * self, e.g. `$self`
|
|
185
|
-
* * base, e.g. `$base`
|
|
186
|
-
*/
|
|
187
|
-
type IncludeString = string;
|
|
188
|
-
type RegExpString = string;
|
|
189
|
-
interface IRawRepositoryMap {
|
|
190
|
-
[name: string]: IRawRule;
|
|
191
|
-
$self: IRawRule;
|
|
192
|
-
$base: IRawRule;
|
|
193
|
-
}
|
|
194
|
-
type IRawRepository = IRawRepositoryMap & ILocatable;
|
|
195
|
-
interface IRawRule extends ILocatable {
|
|
196
|
-
id?: RuleId;
|
|
197
|
-
readonly include?: IncludeString;
|
|
198
|
-
readonly name?: ScopeName;
|
|
199
|
-
readonly contentName?: ScopeName;
|
|
200
|
-
readonly match?: RegExpString;
|
|
201
|
-
readonly captures?: IRawCaptures;
|
|
202
|
-
readonly begin?: RegExpString;
|
|
203
|
-
readonly beginCaptures?: IRawCaptures;
|
|
204
|
-
readonly end?: RegExpString;
|
|
205
|
-
readonly endCaptures?: IRawCaptures;
|
|
206
|
-
readonly while?: RegExpString;
|
|
207
|
-
readonly whileCaptures?: IRawCaptures;
|
|
208
|
-
readonly patterns?: IRawRule[];
|
|
209
|
-
readonly repository?: IRawRepository;
|
|
210
|
-
readonly applyEndPatternLast?: boolean;
|
|
211
|
-
}
|
|
212
|
-
type IRawCaptures = IRawCapturesMap & ILocatable;
|
|
213
|
-
interface IRawCapturesMap {
|
|
214
|
-
[captureId: string]: IRawRule;
|
|
215
|
-
}
|
|
216
|
-
interface ILocation {
|
|
217
|
-
readonly filename: string;
|
|
218
|
-
readonly line: number;
|
|
219
|
-
readonly char: number;
|
|
220
|
-
}
|
|
221
|
-
interface ILocatable {
|
|
222
|
-
readonly $vscodeTextmateLocation?: ILocation;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
declare const enum StandardTokenType$1 {
|
|
226
|
-
Other = 0,
|
|
227
|
-
Comment = 1,
|
|
228
|
-
String = 2,
|
|
229
|
-
RegEx = 3
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* A registry helper that can locate grammar file paths given scope names.
|
|
234
|
-
*/
|
|
235
|
-
interface RegistryOptions {
|
|
236
|
-
onigLib: Promise<IOnigLib>;
|
|
237
|
-
theme?: IRawTheme;
|
|
238
|
-
colorMap?: string[];
|
|
239
|
-
loadGrammar(scopeName: ScopeName): Promise<IRawGrammar | undefined | null>;
|
|
240
|
-
getInjections?(scopeName: ScopeName): ScopeName[] | undefined;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* A map from scope name to a language id. Please do not use language id 0.
|
|
244
|
-
*/
|
|
245
|
-
interface IEmbeddedLanguagesMap {
|
|
246
|
-
[scopeName: string]: number;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* A map from selectors to token types.
|
|
250
|
-
*/
|
|
251
|
-
interface ITokenTypeMap {
|
|
252
|
-
[selector: string]: StandardTokenType$1;
|
|
253
|
-
}
|
|
254
|
-
interface IGrammarConfiguration {
|
|
255
|
-
embeddedLanguages?: IEmbeddedLanguagesMap;
|
|
256
|
-
tokenTypes?: ITokenTypeMap;
|
|
257
|
-
balancedBracketSelectors?: string[];
|
|
258
|
-
unbalancedBracketSelectors?: string[];
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* The registry that will hold all grammars.
|
|
262
|
-
*/
|
|
263
|
-
declare class Registry {
|
|
264
|
-
private readonly _options;
|
|
265
|
-
private readonly _syncRegistry;
|
|
266
|
-
private readonly _ensureGrammarCache;
|
|
267
|
-
constructor(options: RegistryOptions);
|
|
268
|
-
dispose(): void;
|
|
269
|
-
/**
|
|
270
|
-
* Change the theme. Once called, no previous `ruleStack` should be used anymore.
|
|
271
|
-
*/
|
|
272
|
-
setTheme(theme: IRawTheme, colorMap?: string[]): void;
|
|
273
|
-
/**
|
|
274
|
-
* Returns a lookup array for color ids.
|
|
275
|
-
*/
|
|
276
|
-
getColorMap(): string[];
|
|
277
|
-
/**
|
|
278
|
-
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
|
|
279
|
-
* Please do not use language id 0.
|
|
280
|
-
*/
|
|
281
|
-
loadGrammarWithEmbeddedLanguages(initialScopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap): Promise<IGrammar | null>;
|
|
282
|
-
/**
|
|
283
|
-
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
|
|
284
|
-
* Please do not use language id 0.
|
|
285
|
-
*/
|
|
286
|
-
loadGrammarWithConfiguration(initialScopeName: ScopeName, initialLanguage: number, configuration: IGrammarConfiguration): Promise<IGrammar | null>;
|
|
287
|
-
/**
|
|
288
|
-
* Load the grammar for `scopeName` and all referenced included grammars asynchronously.
|
|
289
|
-
*/
|
|
290
|
-
loadGrammar(initialScopeName: ScopeName): Promise<IGrammar | null>;
|
|
291
|
-
private _loadGrammar;
|
|
292
|
-
private _loadSingleGrammar;
|
|
293
|
-
private _doLoadSingleGrammar;
|
|
294
|
-
/**
|
|
295
|
-
* Adds a rawGrammar.
|
|
296
|
-
*/
|
|
297
|
-
addGrammar(rawGrammar: IRawGrammar, injections?: string[], initialLanguage?: number, embeddedLanguages?: IEmbeddedLanguagesMap | null): Promise<IGrammar>;
|
|
298
|
-
/**
|
|
299
|
-
* Get the grammar for `scopeName`. The grammar must first be created via `loadGrammar` or `addGrammar`.
|
|
300
|
-
*/
|
|
301
|
-
private _grammarForScopeName;
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* A grammar
|
|
305
|
-
*/
|
|
306
|
-
interface IGrammar {
|
|
307
|
-
/**
|
|
308
|
-
* Tokenize `lineText` using previous line state `prevState`.
|
|
309
|
-
*/
|
|
310
|
-
tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult;
|
|
311
|
-
/**
|
|
312
|
-
* Tokenize `lineText` using previous line state `prevState`.
|
|
313
|
-
* The result contains the tokens in binary format, resolved with the following information:
|
|
314
|
-
* - language
|
|
315
|
-
* - token type (regex, string, comment, other)
|
|
316
|
-
* - font style
|
|
317
|
-
* - foreground color
|
|
318
|
-
* - background color
|
|
319
|
-
* e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET`
|
|
320
|
-
*/
|
|
321
|
-
tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2;
|
|
322
|
-
}
|
|
323
|
-
interface ITokenizeLineResult {
|
|
324
|
-
readonly tokens: IToken[];
|
|
325
|
-
/**
|
|
326
|
-
* The `prevState` to be passed on to the next line tokenization.
|
|
327
|
-
*/
|
|
328
|
-
readonly ruleStack: StateStack;
|
|
329
|
-
/**
|
|
330
|
-
* Did tokenization stop early due to reaching the time limit.
|
|
331
|
-
*/
|
|
332
|
-
readonly stoppedEarly: boolean;
|
|
333
|
-
}
|
|
334
|
-
interface ITokenizeLineResult2 {
|
|
335
|
-
/**
|
|
336
|
-
* The tokens in binary format. Each token occupies two array indices. For token i:
|
|
337
|
-
* - at offset 2*i => startIndex
|
|
338
|
-
* - at offset 2*i + 1 => metadata
|
|
339
|
-
*
|
|
340
|
-
*/
|
|
341
|
-
readonly tokens: Uint32Array;
|
|
342
|
-
/**
|
|
343
|
-
* The `prevState` to be passed on to the next line tokenization.
|
|
344
|
-
*/
|
|
345
|
-
readonly ruleStack: StateStack;
|
|
346
|
-
/**
|
|
347
|
-
* Did tokenization stop early due to reaching the time limit.
|
|
348
|
-
*/
|
|
349
|
-
readonly stoppedEarly: boolean;
|
|
350
|
-
}
|
|
351
|
-
interface IToken {
|
|
352
|
-
startIndex: number;
|
|
353
|
-
readonly endIndex: number;
|
|
354
|
-
readonly scopes: string[];
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* **IMPORTANT** - Immutable!
|
|
358
|
-
*/
|
|
359
|
-
interface StateStack {
|
|
360
|
-
_stackElementBrand: void;
|
|
361
|
-
readonly depth: number;
|
|
362
|
-
clone(): StateStack;
|
|
363
|
-
equals(other: StateStack): boolean;
|
|
364
|
-
}
|
|
365
|
-
declare const INITIAL: StateStack;
|
|
366
|
-
|
|
367
|
-
declare const enum TemporaryStandardTokenType {
|
|
368
|
-
Other = 0,
|
|
369
|
-
Comment = 1,
|
|
370
|
-
String = 2,
|
|
371
|
-
RegEx = 4,
|
|
372
|
-
MetaEmbedded = 8
|
|
373
|
-
}
|
|
374
|
-
declare const enum StandardTokenType {
|
|
375
|
-
Other = 0,
|
|
376
|
-
Comment = 1,
|
|
377
|
-
String = 2,
|
|
378
|
-
RegEx = 4
|
|
379
|
-
}
|
|
380
|
-
declare class StackElementMetadata {
|
|
381
|
-
static toBinaryStr(metadata: number): string;
|
|
382
|
-
static getLanguageId(metadata: number): number;
|
|
383
|
-
static getTokenType(metadata: number): number;
|
|
384
|
-
static getFontStyle(metadata: number): number;
|
|
385
|
-
static getForeground(metadata: number): number;
|
|
386
|
-
static getBackground(metadata: number): number;
|
|
387
|
-
static containsBalancedBrackets(metadata: number): boolean;
|
|
388
|
-
static set(metadata: number, languageId: number, tokenType: TemporaryStandardTokenType, fontStyle: FontStyle, foreground: number, background: number): number;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
interface PatternScanner extends OnigScanner {
|
|
392
|
-
}
|
|
393
|
-
interface RegexEngineString extends OnigString {
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Engine for RegExp matching and scanning.
|
|
397
|
-
*/
|
|
398
|
-
interface RegexEngine {
|
|
399
|
-
createScanner: (patterns: string[]) => PatternScanner;
|
|
400
|
-
createString: (s: string) => RegexEngineString;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
type Awaitable<T> = T | Promise<T>;
|
|
404
|
-
type MaybeGetter<T> = Awaitable<MaybeModule<T>> | (() => Awaitable<MaybeModule<T>>);
|
|
405
|
-
type MaybeModule<T> = T | {
|
|
406
|
-
default: T;
|
|
407
|
-
};
|
|
408
|
-
type MaybeArray<T> = T | T[];
|
|
409
|
-
type RequireKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
410
|
-
interface Nothing {
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* type StringLiteralUnion<'foo'> = 'foo' | string
|
|
414
|
-
* This has auto completion whereas `'foo' | string` doesn't
|
|
415
|
-
* Adapted from https://github.com/microsoft/TypeScript/issues/29729
|
|
416
|
-
*/
|
|
417
|
-
type StringLiteralUnion<T extends U, U = string> = T | (U & Nothing);
|
|
418
|
-
|
|
419
|
-
type PlainTextLanguage = 'text' | 'plaintext' | 'txt';
|
|
420
|
-
type AnsiLanguage = 'ansi';
|
|
421
|
-
type SpecialLanguage = PlainTextLanguage | AnsiLanguage;
|
|
422
|
-
type LanguageInput = MaybeGetter<MaybeArray<LanguageRegistration>>;
|
|
423
|
-
type ResolveBundleKey<T extends string> = [T] extends [never] ? string : T;
|
|
424
|
-
interface LanguageRegistration extends IRawGrammar {
|
|
425
|
-
name: string;
|
|
426
|
-
scopeName: string;
|
|
427
|
-
displayName?: string;
|
|
428
|
-
aliases?: string[];
|
|
429
|
-
/**
|
|
430
|
-
* A list of languages the current language embeds.
|
|
431
|
-
* If manually specifying languages to load, make sure to load the embedded
|
|
432
|
-
* languages for each parent language.
|
|
433
|
-
*/
|
|
434
|
-
embeddedLangs?: string[];
|
|
435
|
-
/**
|
|
436
|
-
* A list of languages that embed the current language.
|
|
437
|
-
* Unlike `embeddedLangs`, the embedded languages will not be loaded automatically.
|
|
438
|
-
*/
|
|
439
|
-
embeddedLangsLazy?: string[];
|
|
440
|
-
balancedBracketSelectors?: string[];
|
|
441
|
-
unbalancedBracketSelectors?: string[];
|
|
442
|
-
foldingStopMarker?: string;
|
|
443
|
-
foldingStartMarker?: string;
|
|
444
|
-
/**
|
|
445
|
-
* Inject this language to other scopes.
|
|
446
|
-
* Same as `injectTo` in VSCode's `contributes.grammars`.
|
|
447
|
-
*
|
|
448
|
-
* @see https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#injection-grammars
|
|
449
|
-
*/
|
|
450
|
-
injectTo?: string[];
|
|
451
|
-
}
|
|
452
|
-
interface BundledLanguageInfo {
|
|
453
|
-
id: string;
|
|
454
|
-
name: string;
|
|
455
|
-
import: DynamicImportLanguageRegistration;
|
|
456
|
-
aliases?: string[];
|
|
457
|
-
}
|
|
458
|
-
type DynamicImportLanguageRegistration = () => Promise<{
|
|
459
|
-
default: LanguageRegistration[];
|
|
460
|
-
}>;
|
|
461
|
-
|
|
462
|
-
type SpecialTheme = 'none';
|
|
463
|
-
type ThemeInput = MaybeGetter<ThemeRegistrationAny>;
|
|
464
|
-
interface ThemeRegistrationRaw extends IRawTheme, Partial<Omit<ThemeRegistration, 'name' | 'settings'>> {
|
|
465
|
-
}
|
|
466
|
-
interface ThemeRegistration extends Partial<ThemeRegistrationResolved> {
|
|
467
|
-
}
|
|
468
|
-
interface ThemeRegistrationResolved extends IRawTheme {
|
|
469
|
-
/**
|
|
470
|
-
* Theme name
|
|
471
|
-
*/
|
|
472
|
-
name: string;
|
|
473
|
-
/**
|
|
474
|
-
* Display name
|
|
475
|
-
*
|
|
476
|
-
* @field shiki custom property
|
|
477
|
-
*/
|
|
478
|
-
displayName?: string;
|
|
479
|
-
/**
|
|
480
|
-
* Light/dark theme
|
|
481
|
-
*
|
|
482
|
-
* @field shiki custom property
|
|
483
|
-
*/
|
|
484
|
-
type: 'light' | 'dark';
|
|
485
|
-
/**
|
|
486
|
-
* Token rules
|
|
487
|
-
*/
|
|
488
|
-
settings: IRawThemeSetting[];
|
|
489
|
-
/**
|
|
490
|
-
* Same as `settings`, will use as fallback if `settings` is not present.
|
|
491
|
-
*/
|
|
492
|
-
tokenColors?: IRawThemeSetting[];
|
|
493
|
-
/**
|
|
494
|
-
* Default foreground color
|
|
495
|
-
*
|
|
496
|
-
* @field shiki custom property
|
|
497
|
-
*/
|
|
498
|
-
fg: string;
|
|
499
|
-
/**
|
|
500
|
-
* Background color
|
|
501
|
-
*
|
|
502
|
-
* @field shiki custom property
|
|
503
|
-
*/
|
|
504
|
-
bg: string;
|
|
505
|
-
/**
|
|
506
|
-
* A map of color names to new color values.
|
|
507
|
-
*
|
|
508
|
-
* The color key starts with '#' and should be lowercased.
|
|
509
|
-
*
|
|
510
|
-
* @field shiki custom property
|
|
511
|
-
*/
|
|
512
|
-
colorReplacements?: Record<string, string>;
|
|
513
|
-
/**
|
|
514
|
-
* Color map of VS Code options
|
|
515
|
-
*
|
|
516
|
-
* Will be used by shiki on `lang: 'ansi'` to find ANSI colors, and to find the default foreground/background colors.
|
|
517
|
-
*/
|
|
518
|
-
colors?: Record<string, string>;
|
|
519
|
-
/**
|
|
520
|
-
* JSON schema path
|
|
521
|
-
*
|
|
522
|
-
* @field not used by shiki
|
|
523
|
-
*/
|
|
524
|
-
$schema?: string;
|
|
525
|
-
/**
|
|
526
|
-
* Enable semantic highlighting
|
|
527
|
-
*
|
|
528
|
-
* @field not used by shiki
|
|
529
|
-
*/
|
|
530
|
-
semanticHighlighting?: boolean;
|
|
531
|
-
/**
|
|
532
|
-
* Tokens for semantic highlighting
|
|
533
|
-
*
|
|
534
|
-
* @field not used by shiki
|
|
535
|
-
*/
|
|
536
|
-
semanticTokenColors?: Record<string, string>;
|
|
537
|
-
}
|
|
538
|
-
type ThemeRegistrationAny = ThemeRegistrationRaw | ThemeRegistration | ThemeRegistrationResolved;
|
|
539
|
-
type DynamicImportThemeRegistration = () => Promise<{
|
|
540
|
-
default: ThemeRegistration;
|
|
541
|
-
}>;
|
|
542
|
-
interface BundledThemeInfo {
|
|
543
|
-
id: string;
|
|
544
|
-
displayName: string;
|
|
545
|
-
type: 'light' | 'dark';
|
|
546
|
-
import: DynamicImportThemeRegistration;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* GrammarState is a special reference object that holds the state of a grammar.
|
|
551
|
-
*
|
|
552
|
-
* It's used to highlight code snippets that are part of the target language.
|
|
553
|
-
*/
|
|
554
|
-
declare class GrammarState {
|
|
555
|
-
private readonly _stack;
|
|
556
|
-
readonly lang: string;
|
|
557
|
-
readonly theme: string;
|
|
558
|
-
/**
|
|
559
|
-
* Static method to create a initial grammar state.
|
|
560
|
-
*/
|
|
561
|
-
static initial(lang: string, theme: string): GrammarState;
|
|
562
|
-
constructor(_stack: StateStack, lang: string, theme: string);
|
|
563
|
-
get scopes(): string[];
|
|
564
|
-
toJSON(): {
|
|
565
|
-
lang: string;
|
|
566
|
-
theme: string;
|
|
567
|
-
scopes: string[];
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
interface TransformerOptions {
|
|
572
|
-
/**
|
|
573
|
-
* Transformers for the Shiki pipeline.
|
|
574
|
-
*/
|
|
575
|
-
transformers?: ShikiTransformer[];
|
|
576
|
-
}
|
|
577
|
-
interface ShikiTransformerContextMeta {
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* Common transformer context for all transformers hooks
|
|
581
|
-
*/
|
|
582
|
-
interface ShikiTransformerContextCommon {
|
|
583
|
-
meta: ShikiTransformerContextMeta;
|
|
584
|
-
options: CodeToHastOptions;
|
|
585
|
-
codeToHast: (code: string, options: CodeToHastOptions) => Root;
|
|
586
|
-
codeToTokens: (code: string, options: CodeToTokensOptions) => TokensResult;
|
|
587
|
-
}
|
|
588
|
-
interface ShikiTransformerContextSource extends ShikiTransformerContextCommon {
|
|
589
|
-
readonly source: string;
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Transformer context for HAST related hooks
|
|
593
|
-
*/
|
|
594
|
-
interface ShikiTransformerContext extends ShikiTransformerContextSource {
|
|
595
|
-
readonly tokens: ThemedToken[][];
|
|
596
|
-
readonly root: Root;
|
|
597
|
-
readonly pre: Element;
|
|
598
|
-
readonly code: Element;
|
|
599
|
-
readonly lines: Element[];
|
|
600
|
-
readonly structure: CodeToHastOptions['structure'];
|
|
601
|
-
/**
|
|
602
|
-
* Utility to append class to a hast node
|
|
603
|
-
*
|
|
604
|
-
* If the `property.class` is a string, it will be splitted by space and converted to an array.
|
|
605
|
-
*/
|
|
606
|
-
addClassToHast: (hast: Element, className: string | string[]) => Element;
|
|
607
|
-
}
|
|
608
|
-
interface ShikiTransformer {
|
|
609
|
-
/**
|
|
610
|
-
* Name of the transformer
|
|
611
|
-
*/
|
|
612
|
-
name?: string;
|
|
613
|
-
/**
|
|
614
|
-
* Transform the raw input code before passing to the highlighter.
|
|
615
|
-
*/
|
|
616
|
-
preprocess?: (this: ShikiTransformerContextCommon, code: string, options: CodeToHastOptions) => string | void;
|
|
617
|
-
/**
|
|
618
|
-
* Transform the full tokens list before converting to HAST.
|
|
619
|
-
* Return a new tokens list will replace the original one.
|
|
620
|
-
*/
|
|
621
|
-
tokens?: (this: ShikiTransformerContextSource, tokens: ThemedToken[][]) => ThemedToken[][] | void;
|
|
622
|
-
/**
|
|
623
|
-
* Transform the entire generated HAST tree. Return a new Node will replace the original one.
|
|
624
|
-
*/
|
|
625
|
-
root?: (this: ShikiTransformerContext, hast: Root) => Root | void;
|
|
626
|
-
/**
|
|
627
|
-
* Transform the `<pre>` element. Return a new Node will replace the original one.
|
|
628
|
-
*/
|
|
629
|
-
pre?: (this: ShikiTransformerContext, hast: Element) => Element | void;
|
|
630
|
-
/**
|
|
631
|
-
* Transform the `<code>` element. Return a new Node will replace the original one.
|
|
632
|
-
*/
|
|
633
|
-
code?: (this: ShikiTransformerContext, hast: Element) => Element | void;
|
|
634
|
-
/**
|
|
635
|
-
* Transform each line `<span class="line">` element.
|
|
636
|
-
*
|
|
637
|
-
* @param hast
|
|
638
|
-
* @param line 1-based line number
|
|
639
|
-
*/
|
|
640
|
-
line?: (this: ShikiTransformerContext, hast: Element, line: number) => Element | void;
|
|
641
|
-
/**
|
|
642
|
-
* Transform each token `<span>` element.
|
|
643
|
-
*/
|
|
644
|
-
span?: (this: ShikiTransformerContext, hast: Element, line: number, col: number, lineElement: Element) => Element | void;
|
|
645
|
-
/**
|
|
646
|
-
* Transform the generated HTML string before returning.
|
|
647
|
-
* This hook will only be called with `codeToHtml`.
|
|
648
|
-
*/
|
|
649
|
-
postprocess?: (this: ShikiTransformerContextCommon, html: string, options: CodeToHastOptions) => string | void;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
interface DecorationOptions {
|
|
653
|
-
/**
|
|
654
|
-
* Custom decorations to wrap highlighted tokens with.
|
|
655
|
-
*/
|
|
656
|
-
decorations?: DecorationItem[];
|
|
657
|
-
}
|
|
658
|
-
interface DecorationItem {
|
|
659
|
-
/**
|
|
660
|
-
* Start offset or position of the decoration.
|
|
661
|
-
*/
|
|
662
|
-
start: OffsetOrPosition;
|
|
663
|
-
/**
|
|
664
|
-
* End offset or position of the decoration.
|
|
665
|
-
*/
|
|
666
|
-
end: OffsetOrPosition;
|
|
667
|
-
/**
|
|
668
|
-
* Tag name of the element to create.
|
|
669
|
-
* @default 'span'
|
|
670
|
-
*/
|
|
671
|
-
tagName?: string;
|
|
672
|
-
/**
|
|
673
|
-
* Properties of the element to create.
|
|
674
|
-
*/
|
|
675
|
-
properties?: Element['properties'];
|
|
676
|
-
/**
|
|
677
|
-
* A custom function to transform the element after it has been created.
|
|
678
|
-
*/
|
|
679
|
-
transform?: (element: Element, type: DecorationTransformType) => Element | void;
|
|
680
|
-
/**
|
|
681
|
-
* By default when the decoration contains only one token, the decoration will be applied to the token.
|
|
682
|
-
*
|
|
683
|
-
* Set to `true` to always wrap the token with a new element
|
|
684
|
-
*
|
|
685
|
-
* @default false
|
|
686
|
-
*/
|
|
687
|
-
alwaysWrap?: boolean;
|
|
688
|
-
}
|
|
689
|
-
interface ResolvedDecorationItem extends Omit<DecorationItem, 'start' | 'end'> {
|
|
690
|
-
start: ResolvedPosition;
|
|
691
|
-
end: ResolvedPosition;
|
|
692
|
-
}
|
|
693
|
-
type DecorationTransformType = 'wrapper' | 'line' | 'token';
|
|
694
|
-
interface Position {
|
|
695
|
-
line: number;
|
|
696
|
-
character: number;
|
|
697
|
-
}
|
|
698
|
-
type Offset = number;
|
|
699
|
-
type OffsetOrPosition = Position | Offset;
|
|
700
|
-
interface ResolvedPosition extends Position {
|
|
701
|
-
offset: Offset;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
interface HighlighterCoreOptions {
|
|
705
|
-
/**
|
|
706
|
-
* Theme names, or theme registration objects to be loaded upfront.
|
|
707
|
-
*/
|
|
708
|
-
themes?: ThemeInput[];
|
|
709
|
-
/**
|
|
710
|
-
* Language names, or language registration objects to be loaded upfront.
|
|
711
|
-
*/
|
|
712
|
-
langs?: LanguageInput[];
|
|
713
|
-
/**
|
|
714
|
-
* Alias of languages
|
|
715
|
-
* @example { 'my-lang': 'javascript' }
|
|
716
|
-
*/
|
|
717
|
-
langAlias?: Record<string, string>;
|
|
718
|
-
/**
|
|
719
|
-
* Load wasm file from a custom path or using a custom function.
|
|
720
|
-
*/
|
|
721
|
-
loadWasm?: LoadWasmOptions;
|
|
722
|
-
/**
|
|
723
|
-
* Emit console warnings to alert users of potential issues.
|
|
724
|
-
* @default true
|
|
725
|
-
*/
|
|
726
|
-
warnings?: boolean;
|
|
727
|
-
/**
|
|
728
|
-
* Custom RegExp engine.
|
|
729
|
-
*/
|
|
730
|
-
engine?: RegexEngine | Promise<RegexEngine>;
|
|
731
|
-
}
|
|
732
|
-
interface BundledHighlighterOptions<L extends string, T extends string> extends Pick<HighlighterCoreOptions, 'warnings' | 'engine'> {
|
|
733
|
-
/**
|
|
734
|
-
* Theme registation
|
|
735
|
-
*
|
|
736
|
-
* @default []
|
|
737
|
-
*/
|
|
738
|
-
themes: (ThemeInput | StringLiteralUnion<T> | SpecialTheme)[];
|
|
739
|
-
/**
|
|
740
|
-
* Language registation
|
|
741
|
-
*
|
|
742
|
-
* @default []
|
|
743
|
-
*/
|
|
744
|
-
langs: (LanguageInput | StringLiteralUnion<L> | SpecialLanguage)[];
|
|
745
|
-
/**
|
|
746
|
-
* Alias of languages
|
|
747
|
-
* @example { 'my-lang': 'javascript' }
|
|
748
|
-
*/
|
|
749
|
-
langAlias?: Record<string, StringLiteralUnion<L>>;
|
|
750
|
-
}
|
|
751
|
-
interface CodeOptionsSingleTheme<Themes extends string = string> {
|
|
752
|
-
theme: ThemeRegistrationAny | StringLiteralUnion<Themes>;
|
|
753
|
-
}
|
|
754
|
-
interface CodeOptionsMultipleThemes<Themes extends string = string> {
|
|
755
|
-
/**
|
|
756
|
-
* A map of color names to themes.
|
|
757
|
-
* This allows you to specify multiple themes for the generated code.
|
|
758
|
-
*
|
|
759
|
-
* ```ts
|
|
760
|
-
* highlighter.codeToHtml(code, {
|
|
761
|
-
* lang: 'js',
|
|
762
|
-
* themes: {
|
|
763
|
-
* light: 'vitesse-light',
|
|
764
|
-
* dark: 'vitesse-dark',
|
|
765
|
-
* }
|
|
766
|
-
* })
|
|
767
|
-
* ```
|
|
768
|
-
*
|
|
769
|
-
* Will generate:
|
|
770
|
-
*
|
|
771
|
-
* ```html
|
|
772
|
-
* <span style="color:#111;--shiki-dark:#fff;">code</span>
|
|
773
|
-
* ```
|
|
774
|
-
*
|
|
775
|
-
* @see https://github.com/shikijs/shiki#lightdark-dual-themes
|
|
776
|
-
*/
|
|
777
|
-
themes: Partial<Record<string, ThemeRegistrationAny | StringLiteralUnion<Themes>>>;
|
|
778
|
-
/**
|
|
779
|
-
* The default theme applied to the code (via inline `color` style).
|
|
780
|
-
* The rest of the themes are applied via CSS variables, and toggled by CSS overrides.
|
|
781
|
-
*
|
|
782
|
-
* For example, if `defaultColor` is `light`, then `light` theme is applied to the code,
|
|
783
|
-
* and the `dark` theme and other custom themes are applied via CSS variables:
|
|
784
|
-
*
|
|
785
|
-
* ```html
|
|
786
|
-
* <span style="color:#{light};--shiki-dark:#{dark};--shiki-custom:#{custom};">code</span>
|
|
787
|
-
* ```
|
|
788
|
-
*
|
|
789
|
-
* When set to `false`, no default styles will be applied, and totally up to users to apply the styles:
|
|
790
|
-
*
|
|
791
|
-
* ```html
|
|
792
|
-
* <span style="--shiki-light:#{light};--shiki-dark:#{dark};--shiki-custom:#{custom};">code</span>
|
|
793
|
-
* ```
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
* @default 'light'
|
|
797
|
-
*/
|
|
798
|
-
defaultColor?: StringLiteralUnion<'light' | 'dark'> | false;
|
|
799
|
-
/**
|
|
800
|
-
* Prefix of CSS variables used to store the color of the other theme.
|
|
801
|
-
*
|
|
802
|
-
* @default '--shiki-'
|
|
803
|
-
*/
|
|
804
|
-
cssVariablePrefix?: string;
|
|
805
|
-
}
|
|
806
|
-
type CodeOptionsThemes<Themes extends string = string> = CodeOptionsSingleTheme<Themes> | CodeOptionsMultipleThemes<Themes>;
|
|
807
|
-
type CodeToHastOptions<Languages extends string = string, Themes extends string = string> = CodeToHastOptionsCommon<Languages> & CodeOptionsThemes<Themes> & CodeOptionsMeta;
|
|
808
|
-
interface CodeToHastOptionsCommon<Languages extends string = string> extends TransformerOptions, DecorationOptions, Pick<TokenizeWithThemeOptions, 'colorReplacements' | 'tokenizeMaxLineLength' | 'tokenizeTimeLimit' | 'grammarState' | 'grammarContextCode'> {
|
|
809
|
-
lang: StringLiteralUnion<Languages | SpecialLanguage>;
|
|
810
|
-
/**
|
|
811
|
-
* Merge whitespace tokens to saving extra `<span>`.
|
|
812
|
-
*
|
|
813
|
-
* When set to true, it will merge whitespace tokens with the next token.
|
|
814
|
-
* When set to false, it keep the output as-is.
|
|
815
|
-
* When set to `never`, it will force to separate leading and trailing spaces from tokens.
|
|
816
|
-
*
|
|
817
|
-
* @default true
|
|
818
|
-
*/
|
|
819
|
-
mergeWhitespaces?: boolean | 'never';
|
|
820
|
-
/**
|
|
821
|
-
* The structure of the generated HAST and HTML.
|
|
822
|
-
*
|
|
823
|
-
* - `classic`: The classic structure with `<pre>` and `<code>` elements, each line wrapped with a `<span class="line">` element.
|
|
824
|
-
* - `inline`: All tokens are rendered as `<span>`, line breaks are rendered as `<br>`. No `<pre>` or `<code>` elements. Default forground and background colors are not applied.
|
|
825
|
-
*
|
|
826
|
-
* @default 'classic'
|
|
827
|
-
*/
|
|
828
|
-
structure?: 'classic' | 'inline';
|
|
829
|
-
}
|
|
830
|
-
interface CodeOptionsMeta {
|
|
831
|
-
/**
|
|
832
|
-
* Meta data passed to Shiki, usually used by plugin integrations to pass the code block header.
|
|
833
|
-
*
|
|
834
|
-
* Key values in meta will be serialized to the attributes of the root `<pre>` element.
|
|
835
|
-
*
|
|
836
|
-
* Keys starting with `_` will be ignored.
|
|
837
|
-
*
|
|
838
|
-
* A special key `__raw` key will be used to pass the raw code block header (if the integration supports it).
|
|
839
|
-
*/
|
|
840
|
-
meta?: {
|
|
841
|
-
/**
|
|
842
|
-
* Raw string of the code block header.
|
|
843
|
-
*/
|
|
844
|
-
__raw?: string;
|
|
845
|
-
[key: string]: any;
|
|
846
|
-
};
|
|
847
|
-
}
|
|
848
|
-
interface CodeToHastRenderOptionsCommon extends TransformerOptions, Omit<TokensResult, 'tokens'> {
|
|
849
|
-
lang?: string;
|
|
850
|
-
langId?: string;
|
|
851
|
-
}
|
|
852
|
-
type CodeToHastRenderOptions = CodeToHastRenderOptionsCommon & CodeToHastOptions;
|
|
853
|
-
|
|
854
|
-
interface CodeToTokensBaseOptions<Languages extends string = string, Themes extends string = string> extends TokenizeWithThemeOptions {
|
|
855
|
-
lang?: Languages | SpecialLanguage;
|
|
856
|
-
theme?: Themes | ThemeRegistrationAny | SpecialTheme;
|
|
857
|
-
}
|
|
858
|
-
type CodeToTokensOptions<Languages extends string = string, Themes extends string = string> = Omit<CodeToTokensBaseOptions<Languages, Themes>, 'theme'> & CodeOptionsThemes<Themes>;
|
|
859
|
-
interface CodeToTokensWithThemesOptions<Languages = string, Themes = string> {
|
|
860
|
-
lang?: Languages | SpecialLanguage;
|
|
861
|
-
/**
|
|
862
|
-
* A map of color names to themes.
|
|
863
|
-
*
|
|
864
|
-
* `light` and `dark` are required, and arbitrary color names can be added.
|
|
865
|
-
*
|
|
866
|
-
* @example
|
|
867
|
-
* ```ts
|
|
868
|
-
* themes: {
|
|
869
|
-
* light: 'vitesse-light',
|
|
870
|
-
* dark: 'vitesse-dark',
|
|
871
|
-
* soft: 'nord',
|
|
872
|
-
* // custom colors
|
|
873
|
-
* }
|
|
874
|
-
* ```
|
|
875
|
-
*/
|
|
876
|
-
themes: Partial<Record<string, Themes | ThemeRegistrationAny | SpecialTheme>>;
|
|
877
|
-
}
|
|
878
|
-
interface ThemedTokenScopeExplanation {
|
|
879
|
-
scopeName: string;
|
|
880
|
-
themeMatches?: IRawThemeSetting[];
|
|
881
|
-
}
|
|
882
|
-
interface ThemedTokenExplanation {
|
|
883
|
-
content: string;
|
|
884
|
-
scopes: ThemedTokenScopeExplanation[];
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* A single token with color, and optionally with explanation.
|
|
888
|
-
*
|
|
889
|
-
* For example:
|
|
890
|
-
*
|
|
891
|
-
* ```json
|
|
892
|
-
* {
|
|
893
|
-
* "content": "shiki",
|
|
894
|
-
* "color": "#D8DEE9",
|
|
895
|
-
* "explanation": [
|
|
896
|
-
* {
|
|
897
|
-
* "content": "shiki",
|
|
898
|
-
* "scopes": [
|
|
899
|
-
* {
|
|
900
|
-
* "scopeName": "source.js",
|
|
901
|
-
* "themeMatches": []
|
|
902
|
-
* },
|
|
903
|
-
* {
|
|
904
|
-
* "scopeName": "meta.objectliteral.js",
|
|
905
|
-
* "themeMatches": []
|
|
906
|
-
* },
|
|
907
|
-
* {
|
|
908
|
-
* "scopeName": "meta.object.member.js",
|
|
909
|
-
* "themeMatches": []
|
|
910
|
-
* },
|
|
911
|
-
* {
|
|
912
|
-
* "scopeName": "meta.array.literal.js",
|
|
913
|
-
* "themeMatches": []
|
|
914
|
-
* },
|
|
915
|
-
* {
|
|
916
|
-
* "scopeName": "variable.other.object.js",
|
|
917
|
-
* "themeMatches": [
|
|
918
|
-
* {
|
|
919
|
-
* "name": "Variable",
|
|
920
|
-
* "scope": "variable.other",
|
|
921
|
-
* "settings": {
|
|
922
|
-
* "foreground": "#D8DEE9"
|
|
923
|
-
* }
|
|
924
|
-
* },
|
|
925
|
-
* {
|
|
926
|
-
* "name": "[JavaScript] Variable Other Object",
|
|
927
|
-
* "scope": "source.js variable.other.object",
|
|
928
|
-
* "settings": {
|
|
929
|
-
* "foreground": "#D8DEE9"
|
|
930
|
-
* }
|
|
931
|
-
* }
|
|
932
|
-
* ]
|
|
933
|
-
* }
|
|
934
|
-
* ]
|
|
935
|
-
* }
|
|
936
|
-
* ]
|
|
937
|
-
* }
|
|
938
|
-
* ```
|
|
939
|
-
*/
|
|
940
|
-
interface ThemedToken extends TokenStyles, TokenBase {
|
|
941
|
-
}
|
|
942
|
-
interface TokenBase {
|
|
943
|
-
/**
|
|
944
|
-
* The content of the token
|
|
945
|
-
*/
|
|
946
|
-
content: string;
|
|
947
|
-
/**
|
|
948
|
-
* The start offset of the token, relative to the input code. 0-indexed.
|
|
949
|
-
*/
|
|
950
|
-
offset: number;
|
|
951
|
-
/**
|
|
952
|
-
* Explanation of
|
|
953
|
-
*
|
|
954
|
-
* - token text's matching scopes
|
|
955
|
-
* - reason that token text is given a color (one matching scope matches a rule (scope -> color) in the theme)
|
|
956
|
-
*/
|
|
957
|
-
explanation?: ThemedTokenExplanation[];
|
|
958
|
-
}
|
|
959
|
-
interface TokenStyles {
|
|
960
|
-
/**
|
|
961
|
-
* 6 or 8 digit hex code representation of the token's color
|
|
962
|
-
*/
|
|
963
|
-
color?: string;
|
|
964
|
-
/**
|
|
965
|
-
* 6 or 8 digit hex code representation of the token's background color
|
|
966
|
-
*/
|
|
967
|
-
bgColor?: string;
|
|
968
|
-
/**
|
|
969
|
-
* Font style of token. Can be None/Italic/Bold/Underline
|
|
970
|
-
*/
|
|
971
|
-
fontStyle?: FontStyle;
|
|
972
|
-
/**
|
|
973
|
-
* Override with custom inline style for HTML renderer.
|
|
974
|
-
* When specified, `color` and `fontStyle` will be ignored.
|
|
975
|
-
*/
|
|
976
|
-
htmlStyle?: string;
|
|
977
|
-
}
|
|
978
|
-
interface ThemedTokenWithVariants extends TokenBase {
|
|
979
|
-
/**
|
|
980
|
-
* An object of color name to token styles
|
|
981
|
-
*/
|
|
982
|
-
variants: Record<string, TokenStyles>;
|
|
983
|
-
}
|
|
984
|
-
interface TokenizeWithThemeOptions {
|
|
985
|
-
/**
|
|
986
|
-
* Include explanation of why a token is given a color.
|
|
987
|
-
*
|
|
988
|
-
* You can optionally pass `scopeName` to only include explanation for scopes,
|
|
989
|
-
* which is more performant than full explanation.
|
|
990
|
-
*
|
|
991
|
-
* @default false
|
|
992
|
-
*/
|
|
993
|
-
includeExplanation?: boolean | 'scopeName';
|
|
994
|
-
/**
|
|
995
|
-
* A map of color names to new color values.
|
|
996
|
-
*
|
|
997
|
-
* The color key starts with '#' and should be lowercased.
|
|
998
|
-
*
|
|
999
|
-
* This will be merged with theme's `colorReplacements` if any.
|
|
1000
|
-
*/
|
|
1001
|
-
colorReplacements?: Record<string, string | Record<string, string>>;
|
|
1002
|
-
/**
|
|
1003
|
-
* Lines above this length will not be tokenized for performance reasons.
|
|
1004
|
-
*
|
|
1005
|
-
* @default 0 (no limit)
|
|
1006
|
-
*/
|
|
1007
|
-
tokenizeMaxLineLength?: number;
|
|
1008
|
-
/**
|
|
1009
|
-
* Time limit in milliseconds for tokenizing a single line.
|
|
1010
|
-
*
|
|
1011
|
-
* @default 500 (0.5s)
|
|
1012
|
-
*/
|
|
1013
|
-
tokenizeTimeLimit?: number;
|
|
1014
|
-
/**
|
|
1015
|
-
* Represent the state of the grammar, allowing to continue tokenizing from a intermediate grammar state.
|
|
1016
|
-
*
|
|
1017
|
-
* You can get the grammar state from `getLastGrammarState`.
|
|
1018
|
-
*/
|
|
1019
|
-
grammarState?: GrammarState;
|
|
1020
|
-
/**
|
|
1021
|
-
* The code context of the grammar.
|
|
1022
|
-
* Consider it a prepended code to the input code, that only participate the grammar inference but not presented in the final output.
|
|
1023
|
-
*
|
|
1024
|
-
* This will be ignored if `grammarState` is provided.
|
|
1025
|
-
*/
|
|
1026
|
-
grammarContextCode?: string;
|
|
1027
|
-
}
|
|
1028
|
-
/**
|
|
1029
|
-
* Result of `codeToTokens`, an object with 2D array of tokens and meta info like background and foreground color.
|
|
1030
|
-
*/
|
|
1031
|
-
interface TokensResult {
|
|
1032
|
-
/**
|
|
1033
|
-
* 2D array of tokens, first dimension is lines, second dimension is tokens in a line.
|
|
1034
|
-
*/
|
|
1035
|
-
tokens: ThemedToken[][];
|
|
1036
|
-
/**
|
|
1037
|
-
* Foreground color of the code.
|
|
1038
|
-
*/
|
|
1039
|
-
fg?: string;
|
|
1040
|
-
/**
|
|
1041
|
-
* Background color of the code.
|
|
1042
|
-
*/
|
|
1043
|
-
bg?: string;
|
|
1044
|
-
/**
|
|
1045
|
-
* A string representation of themes applied to the token.
|
|
1046
|
-
*/
|
|
1047
|
-
themeName?: string;
|
|
1048
|
-
/**
|
|
1049
|
-
* Custom style string to be applied to the root `<pre>` element.
|
|
1050
|
-
* When specified, `fg` and `bg` will be ignored.
|
|
1051
|
-
*/
|
|
1052
|
-
rootStyle?: string;
|
|
1053
|
-
}
|
|
1054
|
-
declare enum FontStyle {
|
|
1055
|
-
NotSet = -1,
|
|
1056
|
-
None = 0,
|
|
1057
|
-
Italic = 1,
|
|
1058
|
-
Bold = 2,
|
|
1059
|
-
Underline = 4
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
export { type Awaitable as $, type AnsiLanguage as A, type BundledHighlighterOptions as B, type CodeToHastOptions as C, type DynamicImportLanguageRegistration as D, type IRawGrammar as E, type IRawTheme as F, GrammarState as G, type HighlighterCoreOptions as H, type IGrammar as I, type IRawThemeSetting as J, type ThemeRegistrationRaw as K, type LanguageInput as L, type MaybeArray as M, type ThemeRegistration as N, type DynamicImportThemeRegistration as O, type PlainTextLanguage as P, type BundledThemeInfo as Q, type RequireKeys as R, type SpecialLanguage as S, type ThemeInput as T, type ThemedTokenScopeExplanation as U, type ThemedTokenExplanation as V, type TokenBase as W, FontStyle as X, type TransformerOptions as Y, type ShikiTransformerContextMeta as Z, type ShikiTransformerContext as _, type CodeToTokensOptions as a, type MaybeGetter as a0, type MaybeModule as a1, type StringLiteralUnion as a2, type DecorationOptions as a3, type DecorationItem as a4, type ResolvedDecorationItem as a5, type DecorationTransformType as a6, type Offset as a7, type OffsetOrPosition as a8, type ResolvedPosition as a9, type PatternScanner as aa, type RegexEngineString as ab, Registry as ac, INITIAL as ad, type StateStack as ae, Theme as af, type IGrammarConfiguration as ag, type RegistryOptions as ah, TemporaryStandardTokenType as ai, StandardTokenType as aj, StackElementMetadata as ak, type TokensResult as b, type CodeToTokensBaseOptions as c, type ThemedToken as d, type CodeToTokensWithThemesOptions as e, type ThemedTokenWithVariants as f, type SpecialTheme as g, type ThemeRegistrationAny as h, type TokenizeWithThemeOptions as i, type TokenStyles as j, type Position as k, type RegexEngine as l, type ThemeRegistrationResolved as m, type ShikiTransformerContextCommon as n, type CodeToHastRenderOptions as o, type ShikiTransformerContextSource as p, type ShikiTransformer as q, type ResolveBundleKey as r, type LanguageRegistration as s, type BundledLanguageInfo as t, type CodeOptionsSingleTheme as u, type CodeOptionsMultipleThemes as v, type CodeOptionsThemes as w, type CodeToHastOptionsCommon as x, type CodeOptionsMeta as y, type CodeToHastRenderOptionsCommon as z };
|