@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/types.d.mts CHANGED
@@ -1,12 +1,656 @@
1
- import { Root } from 'hast';
2
- import { I as IGrammar, T as ThemeInput, g as SpecialTheme, L as LanguageInput, S as SpecialLanguage, h as ThemeRegistrationAny, m as ThemeRegistrationResolved, s as LanguageRegistration, C as CodeToHastOptions, r as ResolveBundleKey, a as CodeToTokensOptions, b as TokensResult, c as CodeToTokensBaseOptions, d as ThemedToken, e as CodeToTokensWithThemesOptions, f as ThemedTokenWithVariants, G as GrammarState } from './chunk-tokens.mjs';
3
- export { A as AnsiLanguage, $ as Awaitable, B as BundledHighlighterOptions, t as BundledLanguageInfo, Q as BundledThemeInfo, y as CodeOptionsMeta, v as CodeOptionsMultipleThemes, u as CodeOptionsSingleTheme, w as CodeOptionsThemes, x as CodeToHastOptionsCommon, o as CodeToHastRenderOptions, z as CodeToHastRenderOptionsCommon, a4 as DecorationItem, a3 as DecorationOptions, a6 as DecorationTransformType, D as DynamicImportLanguageRegistration, O as DynamicImportThemeRegistration, X as FontStyle, H as HighlighterCoreOptions, M as MaybeArray, a0 as MaybeGetter, a1 as MaybeModule, a7 as Offset, a8 as OffsetOrPosition, P as PlainTextLanguage, k as Position, E as RawGrammar, F as RawTheme, J as RawThemeSetting, R as RequireKeys, a5 as ResolvedDecorationItem, a9 as ResolvedPosition, q as ShikiTransformer, _ as ShikiTransformerContext, n as ShikiTransformerContextCommon, Z as ShikiTransformerContextMeta, p as ShikiTransformerContextSource, a2 as StringLiteralUnion, N as ThemeRegistration, K as ThemeRegistrationRaw, V as ThemedTokenExplanation, U as ThemedTokenScopeExplanation, W as TokenBase, j as TokenStyles, i as TokenizeWithThemeOptions, Y as TransformerOptions } from './chunk-tokens.mjs';
4
- export { L as LoadWasmOptions, a as WebAssemblyInstance, W as WebAssemblyInstantiator } from './chunk-engines.mjs';
1
+ import { Root, Element } from 'hast';
2
+ import { IGrammar, IRawGrammar, IRawTheme, IRawThemeSetting, StateStack } from '@shikijs/vscode-textmate';
3
+ export { IRawGrammar as RawGrammar, IRawTheme as RawTheme, IRawThemeSetting as RawThemeSetting } from '@shikijs/vscode-textmate';
4
+ import { b as MaybeGetter, M as MaybeArray, a as RegexEngine, A as Awaitable, L as LoadWasmOptions, S as StringLiteralUnion } from './chunk-engines.mjs';
5
+ export { J as JavaScriptRegexEngineOptions, f as LoadWasmOptionsPlain, c as MaybeModule, O as OnigurumaLoadOptions, P as PatternScanner, d as RegexEngineString, R as RequireKeys, e as WebAssemblyInstance, W as WebAssemblyInstantiator } from './chunk-engines.mjs';
5
6
 
6
7
  interface Grammar extends IGrammar {
7
8
  name: string;
8
9
  }
9
10
 
11
+ type PlainTextLanguage = 'text' | 'plaintext' | 'txt';
12
+ type AnsiLanguage = 'ansi';
13
+ type SpecialLanguage = PlainTextLanguage | AnsiLanguage;
14
+ type LanguageInput = MaybeGetter<MaybeArray<LanguageRegistration>>;
15
+ type ResolveBundleKey<T extends string> = [T] extends [never] ? string : T;
16
+ interface LanguageRegistration extends IRawGrammar {
17
+ name: string;
18
+ scopeName: string;
19
+ displayName?: string;
20
+ aliases?: string[];
21
+ /**
22
+ * A list of languages the current language embeds.
23
+ * If manually specifying languages to load, make sure to load the embedded
24
+ * languages for each parent language.
25
+ */
26
+ embeddedLangs?: string[];
27
+ /**
28
+ * A list of languages that embed the current language.
29
+ * Unlike `embeddedLangs`, the embedded languages will not be loaded automatically.
30
+ */
31
+ embeddedLangsLazy?: string[];
32
+ balancedBracketSelectors?: string[];
33
+ unbalancedBracketSelectors?: string[];
34
+ foldingStopMarker?: string;
35
+ foldingStartMarker?: string;
36
+ /**
37
+ * Inject this language to other scopes.
38
+ * Same as `injectTo` in VSCode's `contributes.grammars`.
39
+ *
40
+ * @see https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#injection-grammars
41
+ */
42
+ injectTo?: string[];
43
+ }
44
+ interface BundledLanguageInfo {
45
+ id: string;
46
+ name: string;
47
+ import: DynamicImportLanguageRegistration;
48
+ aliases?: string[];
49
+ }
50
+ type DynamicImportLanguageRegistration = () => Promise<{
51
+ default: LanguageRegistration[];
52
+ }>;
53
+
54
+ type SpecialTheme = 'none';
55
+ type ThemeInput = MaybeGetter<ThemeRegistrationAny>;
56
+ interface ThemeRegistrationRaw extends IRawTheme, Partial<Omit<ThemeRegistration, 'name' | 'settings'>> {
57
+ }
58
+ interface ThemeRegistration extends Partial<ThemeRegistrationResolved> {
59
+ }
60
+ interface ThemeRegistrationResolved extends IRawTheme {
61
+ /**
62
+ * Theme name
63
+ */
64
+ name: string;
65
+ /**
66
+ * Display name
67
+ *
68
+ * @field shiki custom property
69
+ */
70
+ displayName?: string;
71
+ /**
72
+ * Light/dark theme
73
+ *
74
+ * @field shiki custom property
75
+ */
76
+ type: 'light' | 'dark';
77
+ /**
78
+ * Token rules
79
+ */
80
+ settings: IRawThemeSetting[];
81
+ /**
82
+ * Same as `settings`, will use as fallback if `settings` is not present.
83
+ */
84
+ tokenColors?: IRawThemeSetting[];
85
+ /**
86
+ * Default foreground color
87
+ *
88
+ * @field shiki custom property
89
+ */
90
+ fg: string;
91
+ /**
92
+ * Background color
93
+ *
94
+ * @field shiki custom property
95
+ */
96
+ bg: string;
97
+ /**
98
+ * A map of color names to new color values.
99
+ *
100
+ * The color key starts with '#' and should be lowercased.
101
+ *
102
+ * @field shiki custom property
103
+ */
104
+ colorReplacements?: Record<string, string>;
105
+ /**
106
+ * Color map of VS Code options
107
+ *
108
+ * Will be used by shiki on `lang: 'ansi'` to find ANSI colors, and to find the default foreground/background colors.
109
+ */
110
+ colors?: Record<string, string>;
111
+ /**
112
+ * JSON schema path
113
+ *
114
+ * @field not used by shiki
115
+ */
116
+ $schema?: string;
117
+ /**
118
+ * Enable semantic highlighting
119
+ *
120
+ * @field not used by shiki
121
+ */
122
+ semanticHighlighting?: boolean;
123
+ /**
124
+ * Tokens for semantic highlighting
125
+ *
126
+ * @field not used by shiki
127
+ */
128
+ semanticTokenColors?: Record<string, string>;
129
+ }
130
+ type ThemeRegistrationAny = ThemeRegistrationRaw | ThemeRegistration | ThemeRegistrationResolved;
131
+ type DynamicImportThemeRegistration = () => Promise<{
132
+ default: ThemeRegistration;
133
+ }>;
134
+ interface BundledThemeInfo {
135
+ id: string;
136
+ displayName: string;
137
+ type: 'light' | 'dark';
138
+ import: DynamicImportThemeRegistration;
139
+ }
140
+
141
+ /**
142
+ * GrammarState is a special reference object that holds the state of a grammar.
143
+ *
144
+ * It's used to highlight code snippets that are part of the target language.
145
+ */
146
+ declare class GrammarState {
147
+ private readonly _stack;
148
+ readonly lang: string;
149
+ readonly theme: string;
150
+ /**
151
+ * Static method to create a initial grammar state.
152
+ */
153
+ static initial(lang: string, theme: string): GrammarState;
154
+ constructor(_stack: StateStack, lang: string, theme: string);
155
+ get scopes(): string[];
156
+ toJSON(): {
157
+ lang: string;
158
+ theme: string;
159
+ scopes: string[];
160
+ };
161
+ }
162
+
163
+ interface TransformerOptions {
164
+ /**
165
+ * Transformers for the Shiki pipeline.
166
+ */
167
+ transformers?: ShikiTransformer[];
168
+ }
169
+ interface ShikiTransformerContextMeta {
170
+ }
171
+ /**
172
+ * Common transformer context for all transformers hooks
173
+ */
174
+ interface ShikiTransformerContextCommon {
175
+ meta: ShikiTransformerContextMeta;
176
+ options: CodeToHastOptions;
177
+ codeToHast: (code: string, options: CodeToHastOptions) => Root;
178
+ codeToTokens: (code: string, options: CodeToTokensOptions) => TokensResult;
179
+ }
180
+ interface ShikiTransformerContextSource extends ShikiTransformerContextCommon {
181
+ readonly source: string;
182
+ }
183
+ /**
184
+ * Transformer context for HAST related hooks
185
+ */
186
+ interface ShikiTransformerContext extends ShikiTransformerContextSource {
187
+ readonly tokens: ThemedToken[][];
188
+ readonly root: Root;
189
+ readonly pre: Element;
190
+ readonly code: Element;
191
+ readonly lines: Element[];
192
+ readonly structure: CodeToHastOptions['structure'];
193
+ /**
194
+ * Utility to append class to a hast node
195
+ *
196
+ * If the `property.class` is a string, it will be splitted by space and converted to an array.
197
+ */
198
+ addClassToHast: (hast: Element, className: string | string[]) => Element;
199
+ }
200
+ interface ShikiTransformer {
201
+ /**
202
+ * Name of the transformer
203
+ */
204
+ name?: string;
205
+ /**
206
+ * Transform the raw input code before passing to the highlighter.
207
+ */
208
+ preprocess?: (this: ShikiTransformerContextCommon, code: string, options: CodeToHastOptions) => string | void;
209
+ /**
210
+ * Transform the full tokens list before converting to HAST.
211
+ * Return a new tokens list will replace the original one.
212
+ */
213
+ tokens?: (this: ShikiTransformerContextSource, tokens: ThemedToken[][]) => ThemedToken[][] | void;
214
+ /**
215
+ * Transform the entire generated HAST tree. Return a new Node will replace the original one.
216
+ */
217
+ root?: (this: ShikiTransformerContext, hast: Root) => Root | void;
218
+ /**
219
+ * Transform the `<pre>` element. Return a new Node will replace the original one.
220
+ */
221
+ pre?: (this: ShikiTransformerContext, hast: Element) => Element | void;
222
+ /**
223
+ * Transform the `<code>` element. Return a new Node will replace the original one.
224
+ */
225
+ code?: (this: ShikiTransformerContext, hast: Element) => Element | void;
226
+ /**
227
+ * Transform each line `<span class="line">` element.
228
+ *
229
+ * @param hast
230
+ * @param line 1-based line number
231
+ */
232
+ line?: (this: ShikiTransformerContext, hast: Element, line: number) => Element | void;
233
+ /**
234
+ * Transform each token `<span>` element.
235
+ */
236
+ span?: (this: ShikiTransformerContext, hast: Element, line: number, col: number, lineElement: Element) => Element | void;
237
+ /**
238
+ * Transform the generated HTML string before returning.
239
+ * This hook will only be called with `codeToHtml`.
240
+ */
241
+ postprocess?: (this: ShikiTransformerContextCommon, html: string, options: CodeToHastOptions) => string | void;
242
+ }
243
+
244
+ interface DecorationOptions {
245
+ /**
246
+ * Custom decorations to wrap highlighted tokens with.
247
+ */
248
+ decorations?: DecorationItem[];
249
+ }
250
+ interface DecorationItem {
251
+ /**
252
+ * Start offset or position of the decoration.
253
+ */
254
+ start: OffsetOrPosition;
255
+ /**
256
+ * End offset or position of the decoration.
257
+ */
258
+ end: OffsetOrPosition;
259
+ /**
260
+ * Tag name of the element to create.
261
+ * @default 'span'
262
+ */
263
+ tagName?: string;
264
+ /**
265
+ * Properties of the element to create.
266
+ */
267
+ properties?: Element['properties'];
268
+ /**
269
+ * A custom function to transform the element after it has been created.
270
+ */
271
+ transform?: (element: Element, type: DecorationTransformType) => Element | void;
272
+ /**
273
+ * By default when the decoration contains only one token, the decoration will be applied to the token.
274
+ *
275
+ * Set to `true` to always wrap the token with a new element
276
+ *
277
+ * @default false
278
+ */
279
+ alwaysWrap?: boolean;
280
+ }
281
+ interface ResolvedDecorationItem extends Omit<DecorationItem, 'start' | 'end'> {
282
+ start: ResolvedPosition;
283
+ end: ResolvedPosition;
284
+ }
285
+ type DecorationTransformType = 'wrapper' | 'line' | 'token';
286
+ interface Position {
287
+ line: number;
288
+ character: number;
289
+ }
290
+ type Offset = number;
291
+ type OffsetOrPosition = Position | Offset;
292
+ interface ResolvedPosition extends Position {
293
+ offset: Offset;
294
+ }
295
+
296
+ interface HighlighterCoreOptions<Sync extends boolean = false> {
297
+ /**
298
+ * Custom RegExp engine.
299
+ */
300
+ engine?: Sync extends true ? RegexEngine : Awaitable<RegexEngine>;
301
+ /**
302
+ * Theme names, or theme registration objects to be loaded upfront.
303
+ */
304
+ themes?: Sync extends true ? MaybeArray<ThemeRegistrationAny>[] : ThemeInput[];
305
+ /**
306
+ * Language names, or language registration objects to be loaded upfront.
307
+ */
308
+ langs?: Sync extends true ? MaybeArray<LanguageRegistration>[] : LanguageInput[];
309
+ /**
310
+ * Alias of languages
311
+ * @example { 'my-lang': 'javascript' }
312
+ */
313
+ langAlias?: Record<string, string>;
314
+ /**
315
+ * Emit console warnings to alert users of potential issues.
316
+ * @default true
317
+ */
318
+ warnings?: boolean;
319
+ /**
320
+ * Load wasm file from a custom path or using a custom function.
321
+ */
322
+ loadWasm?: Sync extends true ? never : LoadWasmOptions;
323
+ }
324
+ interface BundledHighlighterOptions<L extends string, T extends string> extends Pick<HighlighterCoreOptions, 'warnings' | 'engine'> {
325
+ /**
326
+ * Theme registation
327
+ *
328
+ * @default []
329
+ */
330
+ themes: (ThemeInput | StringLiteralUnion<T> | SpecialTheme)[];
331
+ /**
332
+ * Language registation
333
+ *
334
+ * @default []
335
+ */
336
+ langs: (LanguageInput | StringLiteralUnion<L> | SpecialLanguage)[];
337
+ /**
338
+ * Alias of languages
339
+ * @example { 'my-lang': 'javascript' }
340
+ */
341
+ langAlias?: Record<string, StringLiteralUnion<L>>;
342
+ }
343
+ interface CodeOptionsSingleTheme<Themes extends string = string> {
344
+ theme: ThemeRegistrationAny | StringLiteralUnion<Themes>;
345
+ }
346
+ interface CodeOptionsMultipleThemes<Themes extends string = string> {
347
+ /**
348
+ * A map of color names to themes.
349
+ * This allows you to specify multiple themes for the generated code.
350
+ *
351
+ * ```ts
352
+ * highlighter.codeToHtml(code, {
353
+ * lang: 'js',
354
+ * themes: {
355
+ * light: 'vitesse-light',
356
+ * dark: 'vitesse-dark',
357
+ * }
358
+ * })
359
+ * ```
360
+ *
361
+ * Will generate:
362
+ *
363
+ * ```html
364
+ * <span style="color:#111;--shiki-dark:#fff;">code</span>
365
+ * ```
366
+ *
367
+ * @see https://github.com/shikijs/shiki#lightdark-dual-themes
368
+ */
369
+ themes: Partial<Record<string, ThemeRegistrationAny | StringLiteralUnion<Themes>>>;
370
+ /**
371
+ * The default theme applied to the code (via inline `color` style).
372
+ * The rest of the themes are applied via CSS variables, and toggled by CSS overrides.
373
+ *
374
+ * For example, if `defaultColor` is `light`, then `light` theme is applied to the code,
375
+ * and the `dark` theme and other custom themes are applied via CSS variables:
376
+ *
377
+ * ```html
378
+ * <span style="color:#{light};--shiki-dark:#{dark};--shiki-custom:#{custom};">code</span>
379
+ * ```
380
+ *
381
+ * When set to `false`, no default styles will be applied, and totally up to users to apply the styles:
382
+ *
383
+ * ```html
384
+ * <span style="--shiki-light:#{light};--shiki-dark:#{dark};--shiki-custom:#{custom};">code</span>
385
+ * ```
386
+ *
387
+ *
388
+ * @default 'light'
389
+ */
390
+ defaultColor?: StringLiteralUnion<'light' | 'dark'> | false;
391
+ /**
392
+ * Prefix of CSS variables used to store the color of the other theme.
393
+ *
394
+ * @default '--shiki-'
395
+ */
396
+ cssVariablePrefix?: string;
397
+ }
398
+ type CodeOptionsThemes<Themes extends string = string> = CodeOptionsSingleTheme<Themes> | CodeOptionsMultipleThemes<Themes>;
399
+ type CodeToHastOptions<Languages extends string = string, Themes extends string = string> = CodeToHastOptionsCommon<Languages> & CodeOptionsThemes<Themes> & CodeOptionsMeta;
400
+ interface CodeToHastOptionsCommon<Languages extends string = string> extends TransformerOptions, DecorationOptions, Pick<TokenizeWithThemeOptions, 'colorReplacements' | 'tokenizeMaxLineLength' | 'tokenizeTimeLimit' | 'grammarState' | 'grammarContextCode'> {
401
+ lang: StringLiteralUnion<Languages | SpecialLanguage>;
402
+ /**
403
+ * Merge whitespace tokens to saving extra `<span>`.
404
+ *
405
+ * When set to true, it will merge whitespace tokens with the next token.
406
+ * When set to false, it keep the output as-is.
407
+ * When set to `never`, it will force to separate leading and trailing spaces from tokens.
408
+ *
409
+ * @default true
410
+ */
411
+ mergeWhitespaces?: boolean | 'never';
412
+ /**
413
+ * The structure of the generated HAST and HTML.
414
+ *
415
+ * - `classic`: The classic structure with `<pre>` and `<code>` elements, each line wrapped with a `<span class="line">` element.
416
+ * - `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.
417
+ *
418
+ * @default 'classic'
419
+ */
420
+ structure?: 'classic' | 'inline';
421
+ }
422
+ interface CodeOptionsMeta {
423
+ /**
424
+ * Meta data passed to Shiki, usually used by plugin integrations to pass the code block header.
425
+ *
426
+ * Key values in meta will be serialized to the attributes of the root `<pre>` element.
427
+ *
428
+ * Keys starting with `_` will be ignored.
429
+ *
430
+ * A special key `__raw` key will be used to pass the raw code block header (if the integration supports it).
431
+ */
432
+ meta?: {
433
+ /**
434
+ * Raw string of the code block header.
435
+ */
436
+ __raw?: string;
437
+ [key: string]: any;
438
+ };
439
+ }
440
+ interface CodeToHastRenderOptionsCommon extends TransformerOptions, Omit<TokensResult, 'tokens'> {
441
+ lang?: string;
442
+ langId?: string;
443
+ }
444
+ type CodeToHastRenderOptions = CodeToHastRenderOptionsCommon & CodeToHastOptions;
445
+
446
+ interface CodeToTokensBaseOptions<Languages extends string = string, Themes extends string = string> extends TokenizeWithThemeOptions {
447
+ lang?: Languages | SpecialLanguage;
448
+ theme?: Themes | ThemeRegistrationAny | SpecialTheme;
449
+ }
450
+ type CodeToTokensOptions<Languages extends string = string, Themes extends string = string> = Omit<CodeToTokensBaseOptions<Languages, Themes>, 'theme'> & CodeOptionsThemes<Themes>;
451
+ interface CodeToTokensWithThemesOptions<Languages = string, Themes = string> {
452
+ lang?: Languages | SpecialLanguage;
453
+ /**
454
+ * A map of color names to themes.
455
+ *
456
+ * `light` and `dark` are required, and arbitrary color names can be added.
457
+ *
458
+ * @example
459
+ * ```ts
460
+ * themes: {
461
+ * light: 'vitesse-light',
462
+ * dark: 'vitesse-dark',
463
+ * soft: 'nord',
464
+ * // custom colors
465
+ * }
466
+ * ```
467
+ */
468
+ themes: Partial<Record<string, Themes | ThemeRegistrationAny | SpecialTheme>>;
469
+ }
470
+ interface ThemedTokenScopeExplanation {
471
+ scopeName: string;
472
+ themeMatches?: IRawThemeSetting[];
473
+ }
474
+ interface ThemedTokenExplanation {
475
+ content: string;
476
+ scopes: ThemedTokenScopeExplanation[];
477
+ }
478
+ /**
479
+ * A single token with color, and optionally with explanation.
480
+ *
481
+ * For example:
482
+ *
483
+ * ```json
484
+ * {
485
+ * "content": "shiki",
486
+ * "color": "#D8DEE9",
487
+ * "explanation": [
488
+ * {
489
+ * "content": "shiki",
490
+ * "scopes": [
491
+ * {
492
+ * "scopeName": "source.js",
493
+ * "themeMatches": []
494
+ * },
495
+ * {
496
+ * "scopeName": "meta.objectliteral.js",
497
+ * "themeMatches": []
498
+ * },
499
+ * {
500
+ * "scopeName": "meta.object.member.js",
501
+ * "themeMatches": []
502
+ * },
503
+ * {
504
+ * "scopeName": "meta.array.literal.js",
505
+ * "themeMatches": []
506
+ * },
507
+ * {
508
+ * "scopeName": "variable.other.object.js",
509
+ * "themeMatches": [
510
+ * {
511
+ * "name": "Variable",
512
+ * "scope": "variable.other",
513
+ * "settings": {
514
+ * "foreground": "#D8DEE9"
515
+ * }
516
+ * },
517
+ * {
518
+ * "name": "[JavaScript] Variable Other Object",
519
+ * "scope": "source.js variable.other.object",
520
+ * "settings": {
521
+ * "foreground": "#D8DEE9"
522
+ * }
523
+ * }
524
+ * ]
525
+ * }
526
+ * ]
527
+ * }
528
+ * ]
529
+ * }
530
+ * ```
531
+ */
532
+ interface ThemedToken extends TokenStyles, TokenBase {
533
+ }
534
+ interface TokenBase {
535
+ /**
536
+ * The content of the token
537
+ */
538
+ content: string;
539
+ /**
540
+ * The start offset of the token, relative to the input code. 0-indexed.
541
+ */
542
+ offset: number;
543
+ /**
544
+ * Explanation of
545
+ *
546
+ * - token text's matching scopes
547
+ * - reason that token text is given a color (one matching scope matches a rule (scope -> color) in the theme)
548
+ */
549
+ explanation?: ThemedTokenExplanation[];
550
+ }
551
+ interface TokenStyles {
552
+ /**
553
+ * 6 or 8 digit hex code representation of the token's color
554
+ */
555
+ color?: string;
556
+ /**
557
+ * 6 or 8 digit hex code representation of the token's background color
558
+ */
559
+ bgColor?: string;
560
+ /**
561
+ * Font style of token. Can be None/Italic/Bold/Underline
562
+ */
563
+ fontStyle?: FontStyle;
564
+ /**
565
+ * Override with custom inline style for HTML renderer.
566
+ * When specified, `color` and `fontStyle` will be ignored.
567
+ */
568
+ htmlStyle?: string;
569
+ }
570
+ interface ThemedTokenWithVariants extends TokenBase {
571
+ /**
572
+ * An object of color name to token styles
573
+ */
574
+ variants: Record<string, TokenStyles>;
575
+ }
576
+ interface TokenizeWithThemeOptions {
577
+ /**
578
+ * Include explanation of why a token is given a color.
579
+ *
580
+ * You can optionally pass `scopeName` to only include explanation for scopes,
581
+ * which is more performant than full explanation.
582
+ *
583
+ * @default false
584
+ */
585
+ includeExplanation?: boolean | 'scopeName';
586
+ /**
587
+ * A map of color names to new color values.
588
+ *
589
+ * The color key starts with '#' and should be lowercased.
590
+ *
591
+ * This will be merged with theme's `colorReplacements` if any.
592
+ */
593
+ colorReplacements?: Record<string, string | Record<string, string>>;
594
+ /**
595
+ * Lines above this length will not be tokenized for performance reasons.
596
+ *
597
+ * @default 0 (no limit)
598
+ */
599
+ tokenizeMaxLineLength?: number;
600
+ /**
601
+ * Time limit in milliseconds for tokenizing a single line.
602
+ *
603
+ * @default 500 (0.5s)
604
+ */
605
+ tokenizeTimeLimit?: number;
606
+ /**
607
+ * Represent the state of the grammar, allowing to continue tokenizing from a intermediate grammar state.
608
+ *
609
+ * You can get the grammar state from `getLastGrammarState`.
610
+ */
611
+ grammarState?: GrammarState;
612
+ /**
613
+ * The code context of the grammar.
614
+ * Consider it a prepended code to the input code, that only participate the grammar inference but not presented in the final output.
615
+ *
616
+ * This will be ignored if `grammarState` is provided.
617
+ */
618
+ grammarContextCode?: string;
619
+ }
620
+ /**
621
+ * Result of `codeToTokens`, an object with 2D array of tokens and meta info like background and foreground color.
622
+ */
623
+ interface TokensResult {
624
+ /**
625
+ * 2D array of tokens, first dimension is lines, second dimension is tokens in a line.
626
+ */
627
+ tokens: ThemedToken[][];
628
+ /**
629
+ * Foreground color of the code.
630
+ */
631
+ fg?: string;
632
+ /**
633
+ * Background color of the code.
634
+ */
635
+ bg?: string;
636
+ /**
637
+ * A string representation of themes applied to the token.
638
+ */
639
+ themeName?: string;
640
+ /**
641
+ * Custom style string to be applied to the root `<pre>` element.
642
+ * When specified, `fg` and `bg` will be ignored.
643
+ */
644
+ rootStyle?: string;
645
+ }
646
+ declare enum FontStyle {
647
+ NotSet = -1,
648
+ None = 0,
649
+ Italic = 1,
650
+ Bold = 2,
651
+ Underline = 4
652
+ }
653
+
10
654
  /**
11
655
  * Internal context of Shiki, core textmate logic
12
656
  */
@@ -15,10 +659,18 @@ interface ShikiInternal<BundledLangKeys extends string = never, BundledThemeKeys
15
659
  * Load a theme to the highlighter, so later it can be used synchronously.
16
660
  */
17
661
  loadTheme: (...themes: (ThemeInput | BundledThemeKeys | SpecialTheme)[]) => Promise<void>;
662
+ /**
663
+ * Load a theme registration synchronously.
664
+ */
665
+ loadThemeSync: (...themes: MaybeArray<ThemeRegistrationAny>[]) => void;
18
666
  /**
19
667
  * Load a language to the highlighter, so later it can be used synchronously.
20
668
  */
21
669
  loadLanguage: (...langs: (LanguageInput | BundledLangKeys | SpecialLanguage)[]) => Promise<void>;
670
+ /**
671
+ * Load a language registration synchronously.
672
+ */
673
+ loadLanguageSync: (...langs: MaybeArray<LanguageRegistration>[]) => void;
22
674
  /**
23
675
  * Get the registered theme object
24
676
  */
@@ -102,5 +754,13 @@ interface HighlighterGeneric<BundledLangKeys extends string, BundledThemeKeys ex
102
754
  * The fine-grained core Shiki highlighter instance.
103
755
  */
104
756
  type HighlighterCore = HighlighterGeneric<never, never>;
757
+ /**
758
+ * Options for creating a bundled highlighter.
759
+ */
760
+ interface CreatedBundledHighlighterOptions<BundledLangs extends string, BundledThemes extends string> {
761
+ langs: Record<BundledLangs, LanguageInput>;
762
+ themes: Record<BundledThemes, ThemeInput>;
763
+ engine: () => Awaitable<RegexEngine>;
764
+ }
105
765
 
106
- export { CodeToHastOptions, CodeToTokensBaseOptions, CodeToTokensOptions, CodeToTokensWithThemesOptions, type Grammar, GrammarState, type HighlighterCore, type HighlighterGeneric, LanguageInput, LanguageRegistration, ResolveBundleKey, type ShikiInternal, SpecialLanguage, SpecialTheme, ThemeInput, ThemeRegistrationAny, ThemeRegistrationResolved, ThemedToken, ThemedTokenWithVariants, TokensResult };
766
+ export { type AnsiLanguage, Awaitable, type BundledHighlighterOptions, type BundledLanguageInfo, type BundledThemeInfo, type CodeOptionsMeta, type CodeOptionsMultipleThemes, type CodeOptionsSingleTheme, type CodeOptionsThemes, type CodeToHastOptions, type CodeToHastOptionsCommon, type CodeToHastRenderOptions, type CodeToHastRenderOptionsCommon, type CodeToTokensBaseOptions, type CodeToTokensOptions, type CodeToTokensWithThemesOptions, type CreatedBundledHighlighterOptions, type DecorationItem, type DecorationOptions, type DecorationTransformType, type DynamicImportLanguageRegistration, type DynamicImportThemeRegistration, FontStyle, type Grammar, GrammarState, type HighlighterCore, type HighlighterCoreOptions, type HighlighterGeneric, type LanguageInput, type LanguageRegistration, LoadWasmOptions, MaybeArray, MaybeGetter, type Offset, type OffsetOrPosition, type PlainTextLanguage, type Position, RegexEngine, type ResolveBundleKey, type ResolvedDecorationItem, type ResolvedPosition, type ShikiInternal, type ShikiTransformer, type ShikiTransformerContext, type ShikiTransformerContextCommon, type ShikiTransformerContextMeta, type ShikiTransformerContextSource, type SpecialLanguage, type SpecialTheme, StringLiteralUnion, type ThemeInput, type ThemeRegistration, type ThemeRegistrationAny, type ThemeRegistrationRaw, type ThemeRegistrationResolved, type ThemedToken, type ThemedTokenExplanation, type ThemedTokenScopeExplanation, type ThemedTokenWithVariants, type TokenBase, type TokenStyles, type TokenizeWithThemeOptions, type TokensResult, type TransformerOptions };
@@ -1,4 +1,5 @@
1
1
  import { W as WebAssemblyInstantiator } from './chunk-engines.mjs';
2
+ import '@shikijs/vscode-textmate';
2
3
 
3
4
  declare const wasmBinary: ArrayBuffer;
4
5
  declare const getWasmInstance: WebAssemblyInstantiator;