shiki 2.4.1 → 2.5.0

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.
@@ -2,45 +2,7 @@ import { HighlighterGeneric, Awaitable, CodeToHastOptions, CodeToTokensOptions,
2
2
  export * from '@shikijs/types';
3
3
  import { a as RootContent, N as Nodes, R as Root, E as Element } from './types/index.d.mjs';
4
4
  import { JavaScriptRegexEngineOptions } from '@shikijs/engine-javascript';
5
-
6
- declare const enum FontStyle {
7
- NotSet = -1,
8
- None = 0,
9
- Italic = 1,
10
- Bold = 2,
11
- Underline = 4,
12
- Strikethrough = 8
13
- }
14
-
15
- type EncodedTokenAttributes = number;
16
- declare class EncodedTokenMetadata {
17
- static toBinaryStr(encodedTokenAttributes: EncodedTokenAttributes): string;
18
- static print(encodedTokenAttributes: EncodedTokenAttributes): void;
19
- static getLanguageId(encodedTokenAttributes: EncodedTokenAttributes): number;
20
- static getTokenType(encodedTokenAttributes: EncodedTokenAttributes): StandardTokenType;
21
- static containsBalancedBrackets(encodedTokenAttributes: EncodedTokenAttributes): boolean;
22
- static getFontStyle(encodedTokenAttributes: EncodedTokenAttributes): number;
23
- static getForeground(encodedTokenAttributes: EncodedTokenAttributes): number;
24
- static getBackground(encodedTokenAttributes: EncodedTokenAttributes): number;
25
- /**
26
- * Updates the fields in `metadata`.
27
- * A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is.
28
- */
29
- static set(encodedTokenAttributes: EncodedTokenAttributes, languageId: number | 0, tokenType: OptionalStandardTokenType | OptionalStandardTokenType.NotSet, containsBalancedBrackets: boolean | null, fontStyle: FontStyle | FontStyle.NotSet, foreground: number | 0, background: number | 0): number;
30
- }
31
- declare const enum StandardTokenType {
32
- Other = 0,
33
- Comment = 1,
34
- String = 2,
35
- RegEx = 3
36
- }
37
- declare const enum OptionalStandardTokenType {
38
- Other = 0,
39
- Comment = 1,
40
- String = 2,
41
- RegEx = 3,
42
- NotSet = 8
43
- }
5
+ export { FontStyle, EncodedTokenMetadata as StackElementMetadata } from './textmate.mjs';
44
6
 
45
7
  type FormatSmartOptions = {
46
8
  /**
@@ -474,11 +436,15 @@ declare function createCssVariablesTheme(options?: CssVariablesThemeOptions): Th
474
436
  */
475
437
  declare function transformerDecorations(): ShikiTransformer;
476
438
 
439
+ declare function resolveColorReplacements(theme: ThemeRegistrationAny | string, options?: TokenizeWithThemeOptions): Record<string, string | undefined>;
440
+ declare function applyColorReplacements(color: string, replacements?: Record<string, string | undefined>): string;
441
+ declare function applyColorReplacements(color?: string | undefined, replacements?: Record<string, string | undefined>): string | undefined;
442
+
477
443
  declare function toArray<T>(x: MaybeArray<T>): T[];
478
444
  /**
479
- * Split a string into lines, each line preserves the line ending.
445
+ * Normalize a getter to a promise.
480
446
  */
481
- declare function splitLines(code: string, preserveEnding?: boolean): [string, number][];
447
+ declare function normalizeGetter<T>(p: MaybeGetter<T>): Promise<T>;
482
448
  /**
483
449
  * Check if the language is plaintext that is ignored by Shiki.
484
450
  *
@@ -503,31 +469,18 @@ declare function isNoneTheme(theme: string | ThemeInput | null | undefined): the
503
469
  * Hard-coded themes: `none`.
504
470
  */
505
471
  declare function isSpecialTheme(theme: string | ThemeInput | null | undefined): theme is SpecialTheme;
472
+
506
473
  /**
507
474
  * Utility to append class to a hast node
508
475
  *
509
476
  * If the `property.class` is a string, it will be splitted by space and converted to an array.
510
477
  */
511
478
  declare function addClassToHast(node: Element, className: string | string[]): Element;
479
+
512
480
  /**
513
- * Split a token into multiple tokens by given offsets.
514
- *
515
- * The offsets are relative to the token, and should be sorted.
516
- */
517
- declare function splitToken<T extends Pick<ThemedToken, 'content' | 'offset'>>(token: T, offsets: number[]): T[];
518
- /**
519
- * Split 2D tokens array by given breakpoints.
520
- */
521
- declare function splitTokens<T extends Pick<ThemedToken, 'content' | 'offset'>>(tokens: T[][], breakpoints: number[] | Set<number>): T[][];
522
- /**
523
- * Normalize a getter to a promise.
481
+ * Split a string into lines, each line preserves the line ending.
524
482
  */
525
- declare function normalizeGetter<T>(p: MaybeGetter<T>): Promise<T>;
526
- declare function resolveColorReplacements(theme: ThemeRegistrationAny | string, options?: TokenizeWithThemeOptions): Record<string, string | undefined>;
527
- declare function applyColorReplacements(color: string, replacements?: Record<string, string | undefined>): string;
528
- declare function applyColorReplacements(color?: string | undefined, replacements?: Record<string, string | undefined>): string | undefined;
529
- declare function getTokenStyleObject(token: TokenStyles): Record<string, string>;
530
- declare function stringifyTokenStyle(token: string | Record<string, string>): string;
483
+ declare function splitLines(code: string, preserveEnding?: boolean): [string, number][];
531
484
  /**
532
485
  * Creates a converter between index and position in a code block.
533
486
  *
@@ -545,6 +498,20 @@ declare function createPositionConverter(code: string): {
545
498
  */
546
499
  declare function guessEmbeddedLanguages(code: string, _lang: string | undefined, highlighter?: HighlighterGeneric<any, any>): string[];
547
500
 
501
+ /**
502
+ * Split a token into multiple tokens by given offsets.
503
+ *
504
+ * The offsets are relative to the token, and should be sorted.
505
+ */
506
+ declare function splitToken<T extends Pick<ThemedToken, 'content' | 'offset'>>(token: T, offsets: number[]): T[];
507
+ /**
508
+ * Split 2D tokens array by given breakpoints.
509
+ */
510
+ declare function splitTokens<T extends Pick<ThemedToken, 'content' | 'offset'>>(tokens: T[][], breakpoints: number[] | Set<number>): T[][];
511
+ declare function flatTokenVariants(merged: ThemedTokenWithVariants, variantsOrder: string[], cssVariablePrefix: string, defaultColor: string | boolean): ThemedToken;
512
+ declare function getTokenStyleObject(token: TokenStyles): Record<string, string>;
513
+ declare function stringifyTokenStyle(token: string | Record<string, string>): string;
514
+
548
515
  type DeprecationTarget = 3;
549
516
  /**
550
517
  * Enable runtime warning for deprecated APIs, for the future versions of Shiki.
@@ -559,4 +526,4 @@ declare function enableDeprecationWarnings(emitDeprecation?: DeprecationTarget |
559
526
  */
560
527
  declare function warnDeprecated(message: string, version?: DeprecationTarget): void;
561
528
 
562
- export { type CreateSingletonShorthandsOptions, type CssVariablesThemeOptions, FontStyle, type ShorthandsBundle, EncodedTokenMetadata as StackElementMetadata, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, enableDeprecationWarnings, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, guessEmbeddedLanguages, toHtml as hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
529
+ export { type CreateSingletonShorthandsOptions, type CssVariablesThemeOptions, type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createCssVariablesTheme, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createOnigurumaEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, enableDeprecationWarnings, flatTokenVariants, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, guessEmbeddedLanguages, toHtml as hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations, warnDeprecated };
@@ -1,4 +1 @@
1
- import { setDefaultWasmLoader } from '@shikijs/engine-oniguruma';
2
1
  export * from '@shikijs/core';
3
-
4
- setDefaultWasmLoader(() => import('shiki/wasm'));
package/dist/core.d.mts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from '@shikijs/core';
2
2
  import '@shikijs/engine-oniguruma/wasm-inlined';
3
3
  import '@shikijs/engine-javascript';
4
- import '@shikijs/vscode-textmate';
4
+ import '@shikijs/engine-oniguruma';
@@ -1,87 +1 @@
1
- interface IOnigCaptureIndex {
2
- start: number;
3
- end: number;
4
- length: number;
5
- }
6
- interface IOnigMatch {
7
- index: number;
8
- captureIndices: IOnigCaptureIndex[];
9
- }
10
- declare const enum FindOption {
11
- None = 0,
12
- /**
13
- * equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
14
- */
15
- NotBeginString = 1,
16
- /**
17
- * equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
18
- */
19
- NotEndString = 2,
20
- /**
21
- * equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
22
- */
23
- NotBeginPosition = 4,
24
- /**
25
- * used for debugging purposes.
26
- */
27
- DebugCall = 8
28
- }
29
- interface OnigScanner {
30
- findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
31
- dispose?(): void;
32
- }
33
- interface OnigString {
34
- readonly content: string;
35
- dispose?(): void;
36
- }
37
-
38
- /**
39
- * A union of given const enum values.
40
- */
41
- type OrMask<T extends number> = number;
42
-
43
- type Awaitable<T> = T | Promise<T>;
44
-
45
- interface PatternScanner extends OnigScanner {
46
- }
47
- interface RegexEngineString extends OnigString {
48
- }
49
- /**
50
- * Engine for RegExp matching and scanning.
51
- */
52
- interface RegexEngine {
53
- createScanner: (patterns: (string | RegExp)[]) => PatternScanner;
54
- createString: (s: string) => RegexEngineString;
55
- }
56
- interface WebAssemblyInstantiator {
57
- (importObject: Record<string, Record<string, WebAssembly.ImportValue>> | undefined): Promise<WebAssemblyInstance>;
58
- }
59
- type WebAssemblyInstance = WebAssembly.WebAssemblyInstantiatedSource | WebAssembly.Instance | WebAssembly.Instance['exports'];
60
- type OnigurumaLoadOptions = {
61
- instantiator: WebAssemblyInstantiator;
62
- } | {
63
- default: WebAssemblyInstantiator;
64
- } | {
65
- data: ArrayBufferView | ArrayBuffer | Response;
66
- };
67
- type LoadWasmOptionsPlain = OnigurumaLoadOptions | WebAssemblyInstantiator | ArrayBufferView | ArrayBuffer | Response;
68
- type LoadWasmOptions = Awaitable<LoadWasmOptionsPlain> | (() => Awaitable<LoadWasmOptionsPlain>);
69
-
70
- declare function loadWasm(options: LoadWasmOptions): Promise<void>;
71
-
72
- /**
73
- * Set the default wasm loader for `loadWasm`.
74
- * @internal
75
- */
76
- declare function setDefaultWasmLoader(_loader: LoadWasmOptions): void;
77
- /**
78
- * @internal
79
- */
80
- declare function getDefaultWasmLoader(): LoadWasmOptions | undefined;
81
- declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
82
- /**
83
- * @deprecated Use `createOnigurumaEngine` instead.
84
- */
85
- declare function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
86
-
87
- export { createOnigurumaEngine, createWasmOnigEngine, getDefaultWasmLoader, loadWasm, setDefaultWasmLoader };
1
+ export * from '@shikijs/engine-oniguruma';
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  export { Highlighter, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighter, getHighlighter, getLastGrammarState, getSingletonHighlighter } from './bundle-full.mjs';
2
2
  export { BuiltinLanguage, BuiltinTheme } from './types.mjs';
3
3
  export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
4
- export { createOnigurumaEngine, loadWasm } from './engine-oniguruma.mjs';
5
4
  export { g as getWasmInlined } from './types/wasm-dynamic.mjs';
6
5
  export * from '@shikijs/core';
7
6
  export { BundledLanguage, bundledLanguages, bundledLanguagesAlias, bundledLanguagesBase, bundledLanguagesInfo } from './langs.mjs';
@@ -9,3 +8,77 @@ export { BundledTheme, bundledThemes, bundledThemesInfo } from './themes.mjs';
9
8
  import './types/index.d.mjs';
10
9
  import '@shikijs/types';
11
10
  import '@shikijs/core/types';
11
+
12
+ interface IOnigCaptureIndex {
13
+ start: number;
14
+ end: number;
15
+ length: number;
16
+ }
17
+ interface IOnigMatch {
18
+ index: number;
19
+ captureIndices: IOnigCaptureIndex[];
20
+ }
21
+ declare const enum FindOption {
22
+ None = 0,
23
+ /**
24
+ * equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
25
+ */
26
+ NotBeginString = 1,
27
+ /**
28
+ * equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
29
+ */
30
+ NotEndString = 2,
31
+ /**
32
+ * equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
33
+ */
34
+ NotBeginPosition = 4,
35
+ /**
36
+ * used for debugging purposes.
37
+ */
38
+ DebugCall = 8
39
+ }
40
+ interface OnigScanner {
41
+ findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
42
+ dispose?(): void;
43
+ }
44
+ interface OnigString {
45
+ readonly content: string;
46
+ dispose?(): void;
47
+ }
48
+
49
+ /**
50
+ * A union of given const enum values.
51
+ */
52
+ type OrMask<T extends number> = number;
53
+
54
+ type Awaitable<T> = T | Promise<T>;
55
+
56
+ interface PatternScanner extends OnigScanner {
57
+ }
58
+ interface RegexEngineString extends OnigString {
59
+ }
60
+ /**
61
+ * Engine for RegExp matching and scanning.
62
+ */
63
+ interface RegexEngine {
64
+ createScanner: (patterns: (string | RegExp)[]) => PatternScanner;
65
+ createString: (s: string) => RegexEngineString;
66
+ }
67
+ interface WebAssemblyInstantiator {
68
+ (importObject: Record<string, Record<string, WebAssembly.ImportValue>> | undefined): Promise<WebAssemblyInstance>;
69
+ }
70
+ type WebAssemblyInstance = WebAssembly.WebAssemblyInstantiatedSource | WebAssembly.Instance | WebAssembly.Instance['exports'];
71
+ type OnigurumaLoadOptions = {
72
+ instantiator: WebAssemblyInstantiator;
73
+ } | {
74
+ default: WebAssemblyInstantiator;
75
+ } | {
76
+ data: ArrayBufferView | ArrayBuffer | Response;
77
+ };
78
+ type LoadWasmOptionsPlain = OnigurumaLoadOptions | WebAssemblyInstantiator | ArrayBufferView | ArrayBuffer | Response;
79
+ type LoadWasmOptions = Awaitable<LoadWasmOptionsPlain> | (() => Awaitable<LoadWasmOptionsPlain>);
80
+
81
+ declare function loadWasm(options: LoadWasmOptions): Promise<void>;
82
+ declare function createOnigurumaEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
83
+
84
+ export { createOnigurumaEngine, loadWasm };
@@ -1 +1,711 @@
1
- export * from '@shikijs/vscode-textmate';
1
+ declare const ruleIdSymbol: unique symbol;
2
+ type RuleId = {
3
+ __brand: typeof ruleIdSymbol;
4
+ };
5
+ declare const endRuleId = -1;
6
+ interface IRuleRegistry {
7
+ getRule(ruleId: RuleId): Rule;
8
+ registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
9
+ }
10
+ interface IGrammarRegistry {
11
+ getExternalGrammar(scopeName: string, repository: IRawRepository): IRawGrammar | null | undefined;
12
+ }
13
+ interface IRuleFactoryHelper extends IRuleRegistry, IGrammarRegistry {
14
+ }
15
+ declare abstract class Rule {
16
+ readonly $location: ILocation | undefined;
17
+ readonly id: RuleId;
18
+ private readonly _nameIsCapturing;
19
+ private readonly _name;
20
+ private readonly _contentNameIsCapturing;
21
+ private readonly _contentName;
22
+ constructor($location: ILocation | undefined, id: RuleId, name: string | null | undefined, contentName: string | null | undefined);
23
+ abstract dispose(): void;
24
+ get debugName(): string;
25
+ getName(lineText: string | null, captureIndices: IOnigCaptureIndex[] | null): string | null;
26
+ getContentName(lineText: string, captureIndices: IOnigCaptureIndex[]): string | null;
27
+ abstract collectPatterns(grammar: IRuleRegistry, out: RegExpSourceList): void;
28
+ abstract compile(grammar: IRuleRegistry & IOnigLib, endRegexSource: RegExpString | null): CompiledRule;
29
+ abstract compileAG(grammar: IRuleRegistry & IOnigLib, endRegexSource: RegExpString | null, allowA: boolean, allowG: boolean): CompiledRule;
30
+ }
31
+ declare class RegExpSource<TRuleId = RuleId | typeof endRuleId> {
32
+ source: RegExpString;
33
+ readonly ruleId: TRuleId;
34
+ hasAnchor: boolean;
35
+ readonly hasBackReferences: boolean;
36
+ private _anchorCache;
37
+ constructor(regExpSource: RegExpString, ruleId: TRuleId);
38
+ clone(): RegExpSource<TRuleId>;
39
+ setSource(newSource: RegExpString): void;
40
+ resolveBackReferences(lineText: string, captureIndices: IOnigCaptureIndex[]): string;
41
+ private _buildAnchorCache;
42
+ resolveAnchors(allowA: boolean, allowG: boolean): RegExpString;
43
+ }
44
+ declare class RegExpSourceList<TRuleId = RuleId | typeof endRuleId> {
45
+ private readonly _items;
46
+ private _hasAnchors;
47
+ private _cached;
48
+ private _anchorCache;
49
+ constructor();
50
+ dispose(): void;
51
+ private _disposeCaches;
52
+ push(item: RegExpSource<TRuleId>): void;
53
+ unshift(item: RegExpSource<TRuleId>): void;
54
+ length(): number;
55
+ setSource(index: number, newSource: RegExpString): void;
56
+ compile(onigLib: IOnigLib): CompiledRule<TRuleId>;
57
+ compileAG(onigLib: IOnigLib, allowA: boolean, allowG: boolean): CompiledRule<TRuleId>;
58
+ private _resolveAnchors;
59
+ }
60
+ declare class CompiledRule<TRuleId = RuleId | typeof endRuleId> {
61
+ private readonly regExps;
62
+ private readonly rules;
63
+ private readonly scanner;
64
+ constructor(onigLib: IOnigLib, regExps: RegExpString[], rules: TRuleId[]);
65
+ dispose(): void;
66
+ toString(): string;
67
+ findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IFindNextMatchResult<TRuleId> | null;
68
+ }
69
+ interface IFindNextMatchResult<TRuleId = RuleId | typeof endRuleId> {
70
+ ruleId: TRuleId;
71
+ captureIndices: IOnigCaptureIndex[];
72
+ }
73
+
74
+ interface IRawGrammar extends ILocatable {
75
+ repository: IRawRepository;
76
+ readonly scopeName: ScopeName;
77
+ readonly patterns: IRawRule[];
78
+ readonly injections?: {
79
+ [expression: string]: IRawRule;
80
+ };
81
+ readonly injectionSelector?: string;
82
+ readonly fileTypes?: string[];
83
+ readonly name?: string;
84
+ readonly firstLineMatch?: string;
85
+ }
86
+ /**
87
+ * Allowed values:
88
+ * * Scope Name, e.g. `source.ts`
89
+ * * Top level scope reference, e.g. `source.ts#entity.name.class`
90
+ * * Relative scope reference, e.g. `#entity.name.class`
91
+ * * self, e.g. `$self`
92
+ * * base, e.g. `$base`
93
+ */
94
+ type IncludeString = string;
95
+ type RegExpString = string | RegExp;
96
+ interface IRawRepositoryMap {
97
+ [name: string]: IRawRule;
98
+ }
99
+ type IRawRepository = IRawRepositoryMap & ILocatable;
100
+ interface IRawRule extends ILocatable {
101
+ id?: RuleId;
102
+ readonly include?: IncludeString;
103
+ readonly name?: ScopeName;
104
+ readonly contentName?: ScopeName;
105
+ readonly match?: RegExpString;
106
+ readonly captures?: IRawCaptures;
107
+ readonly begin?: RegExpString;
108
+ readonly beginCaptures?: IRawCaptures;
109
+ readonly end?: RegExpString;
110
+ readonly endCaptures?: IRawCaptures;
111
+ readonly while?: RegExpString;
112
+ readonly whileCaptures?: IRawCaptures;
113
+ readonly patterns?: IRawRule[];
114
+ readonly repository?: IRawRepository;
115
+ readonly applyEndPatternLast?: boolean;
116
+ }
117
+ type IRawCaptures = IRawCapturesMap & ILocatable;
118
+ interface IRawCapturesMap {
119
+ [captureId: string]: IRawRule;
120
+ }
121
+ interface ILocation {
122
+ readonly filename: string;
123
+ readonly line: number;
124
+ readonly char: number;
125
+ }
126
+ interface ILocatable {
127
+ readonly $vscodeTextmateLocation?: ILocation;
128
+ }
129
+
130
+ interface IOnigLib {
131
+ createOnigScanner(sources: RegExpString[]): OnigScanner;
132
+ createOnigString(str: string): OnigString;
133
+ }
134
+ interface IOnigCaptureIndex {
135
+ start: number;
136
+ end: number;
137
+ length: number;
138
+ }
139
+ interface IOnigMatch {
140
+ index: number;
141
+ captureIndices: IOnigCaptureIndex[];
142
+ }
143
+ declare const enum FindOption {
144
+ None = 0,
145
+ /**
146
+ * equivalent of ONIG_OPTION_NOT_BEGIN_STRING: (str) isn't considered as begin of string (* fail \A)
147
+ */
148
+ NotBeginString = 1,
149
+ /**
150
+ * equivalent of ONIG_OPTION_NOT_END_STRING: (end) isn't considered as end of string (* fail \z, \Z)
151
+ */
152
+ NotEndString = 2,
153
+ /**
154
+ * equivalent of ONIG_OPTION_NOT_BEGIN_POSITION: (start) isn't considered as start position of search (* fail \G)
155
+ */
156
+ NotBeginPosition = 4,
157
+ /**
158
+ * used for debugging purposes.
159
+ */
160
+ DebugCall = 8
161
+ }
162
+ interface OnigScanner {
163
+ findNextMatchSync(string: string | OnigString, startPosition: number, options: OrMask<FindOption>): IOnigMatch | null;
164
+ dispose?(): void;
165
+ }
166
+ interface OnigString {
167
+ readonly content: string;
168
+ dispose?(): void;
169
+ }
170
+ declare function disposeOnigString(str: OnigString): void;
171
+
172
+ /**
173
+ * A union of given const enum values.
174
+ */
175
+ type OrMask<T extends number> = number;
176
+
177
+ declare class Theme {
178
+ private readonly _colorMap;
179
+ private readonly _defaults;
180
+ private readonly _root;
181
+ static createFromRawTheme(source: IRawTheme | undefined, colorMap?: string[]): Theme;
182
+ static createFromParsedTheme(source: ParsedThemeRule[], colorMap?: string[]): Theme;
183
+ private readonly _cachedMatchRoot;
184
+ constructor(_colorMap: ColorMap, _defaults: StyleAttributes, _root: ThemeTrieElement);
185
+ getColorMap(): string[];
186
+ getDefaults(): StyleAttributes;
187
+ match(scopePath: ScopeStack | null): StyleAttributes | null;
188
+ }
189
+ /**
190
+ * Identifiers with a binary dot operator.
191
+ * Examples: `baz` or `foo.bar`
192
+ */
193
+ type ScopeName = string;
194
+ /**
195
+ * An expression language of ScopeNames with a binary space (to indicate nesting) operator.
196
+ * Examples: `foo.bar boo.baz`
197
+ */
198
+ type ScopePath = string;
199
+ /**
200
+ * An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator.
201
+ * Examples: `foo.bar boo.baz,quick quack`
202
+ */
203
+ type ScopePattern = string;
204
+ /**
205
+ * A TextMate theme.
206
+ */
207
+ interface IRawTheme {
208
+ readonly name?: string;
209
+ readonly settings: IRawThemeSetting[];
210
+ }
211
+ /**
212
+ * A single theme setting.
213
+ */
214
+ interface IRawThemeSetting {
215
+ readonly name?: string;
216
+ readonly scope?: ScopePattern | ScopePattern[];
217
+ readonly settings: {
218
+ readonly fontStyle?: string;
219
+ readonly foreground?: string;
220
+ readonly background?: string;
221
+ };
222
+ }
223
+ declare class ScopeStack {
224
+ readonly parent: ScopeStack | null;
225
+ readonly scopeName: ScopeName;
226
+ static push(path: ScopeStack | null, scopeNames: ScopeName[]): ScopeStack | null;
227
+ static from(first: ScopeName, ...segments: ScopeName[]): ScopeStack;
228
+ static from(...segments: ScopeName[]): ScopeStack | null;
229
+ constructor(parent: ScopeStack | null, scopeName: ScopeName);
230
+ push(scopeName: ScopeName): ScopeStack;
231
+ getSegments(): ScopeName[];
232
+ toString(): string;
233
+ extends(other: ScopeStack): boolean;
234
+ getExtensionIfDefined(base: ScopeStack | null): string[] | undefined;
235
+ }
236
+ declare class StyleAttributes {
237
+ readonly fontStyle: OrMask<FontStyle>;
238
+ readonly foregroundId: number;
239
+ readonly backgroundId: number;
240
+ constructor(fontStyle: OrMask<FontStyle>, foregroundId: number, backgroundId: number);
241
+ }
242
+ declare class ParsedThemeRule {
243
+ readonly scope: ScopeName;
244
+ readonly parentScopes: ScopeName[] | null;
245
+ readonly index: number;
246
+ readonly fontStyle: OrMask<FontStyle>;
247
+ readonly foreground: string | null;
248
+ readonly background: string | null;
249
+ constructor(scope: ScopeName, parentScopes: ScopeName[] | null, index: number, fontStyle: OrMask<FontStyle>, foreground: string | null, background: string | null);
250
+ }
251
+ declare const enum FontStyle {
252
+ NotSet = -1,
253
+ None = 0,
254
+ Italic = 1,
255
+ Bold = 2,
256
+ Underline = 4,
257
+ Strikethrough = 8
258
+ }
259
+ declare class ColorMap {
260
+ private readonly _isFrozen;
261
+ private _lastColorId;
262
+ private _id2color;
263
+ private _color2id;
264
+ constructor(_colorMap?: string[]);
265
+ getId(color: string | null): number;
266
+ getColorMap(): string[];
267
+ }
268
+ declare class ThemeTrieElementRule {
269
+ scopeDepth: number;
270
+ parentScopes: readonly ScopeName[];
271
+ fontStyle: number;
272
+ foreground: number;
273
+ background: number;
274
+ constructor(scopeDepth: number, parentScopes: readonly ScopeName[] | null, fontStyle: number, foreground: number, background: number);
275
+ clone(): ThemeTrieElementRule;
276
+ static cloneArr(arr: ThemeTrieElementRule[]): ThemeTrieElementRule[];
277
+ acceptOverwrite(scopeDepth: number, fontStyle: number, foreground: number, background: number): void;
278
+ }
279
+ interface ITrieChildrenMap {
280
+ [segment: string]: ThemeTrieElement;
281
+ }
282
+ declare class ThemeTrieElement {
283
+ private readonly _mainRule;
284
+ private readonly _children;
285
+ private readonly _rulesWithParentScopes;
286
+ constructor(_mainRule: ThemeTrieElementRule, rulesWithParentScopes?: ThemeTrieElementRule[], _children?: ITrieChildrenMap);
287
+ private static _cmpBySpecificity;
288
+ match(scope: ScopeName): ThemeTrieElementRule[];
289
+ insert(scopeDepth: number, scope: ScopeName, parentScopes: ScopeName[] | null, fontStyle: number, foreground: number, background: number): void;
290
+ private _doInsertHere;
291
+ }
292
+
293
+ type EncodedTokenAttributes = number;
294
+ declare class EncodedTokenMetadata {
295
+ static toBinaryStr(encodedTokenAttributes: EncodedTokenAttributes): string;
296
+ static print(encodedTokenAttributes: EncodedTokenAttributes): void;
297
+ static getLanguageId(encodedTokenAttributes: EncodedTokenAttributes): number;
298
+ static getTokenType(encodedTokenAttributes: EncodedTokenAttributes): StandardTokenType;
299
+ static containsBalancedBrackets(encodedTokenAttributes: EncodedTokenAttributes): boolean;
300
+ static getFontStyle(encodedTokenAttributes: EncodedTokenAttributes): number;
301
+ static getForeground(encodedTokenAttributes: EncodedTokenAttributes): number;
302
+ static getBackground(encodedTokenAttributes: EncodedTokenAttributes): number;
303
+ /**
304
+ * Updates the fields in `metadata`.
305
+ * A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is.
306
+ */
307
+ static set(encodedTokenAttributes: EncodedTokenAttributes, languageId: number | 0, tokenType: OptionalStandardTokenType | OptionalStandardTokenType.NotSet, containsBalancedBrackets: boolean | null, fontStyle: FontStyle | FontStyle.NotSet, foreground: number | 0, background: number | 0): number;
308
+ }
309
+ declare const enum StandardTokenType {
310
+ Other = 0,
311
+ Comment = 1,
312
+ String = 2,
313
+ RegEx = 3
314
+ }
315
+ declare const enum OptionalStandardTokenType {
316
+ Other = 0,
317
+ Comment = 1,
318
+ String = 2,
319
+ RegEx = 3,
320
+ NotSet = 8
321
+ }
322
+
323
+ interface Matcher<T> {
324
+ (matcherInput: T): boolean;
325
+ }
326
+
327
+ declare class BasicScopeAttributes {
328
+ readonly languageId: number;
329
+ readonly tokenType: OptionalStandardTokenType;
330
+ constructor(languageId: number, tokenType: OptionalStandardTokenType);
331
+ }
332
+
333
+ interface IThemeProvider {
334
+ themeMatch(scopePath: ScopeStack): StyleAttributes | null;
335
+ getDefaults(): StyleAttributes;
336
+ }
337
+ interface IGrammarRepository {
338
+ lookup(scopeName: ScopeName): IRawGrammar | undefined;
339
+ injections(scopeName: ScopeName): ScopeName[];
340
+ }
341
+ interface Injection {
342
+ readonly debugSelector: string;
343
+ readonly matcher: Matcher<string[]>;
344
+ readonly priority: -1 | 0 | 1;
345
+ readonly ruleId: RuleId;
346
+ readonly grammar: IRawGrammar;
347
+ }
348
+ declare class Grammar implements IGrammar, IRuleFactoryHelper, IOnigLib {
349
+ private readonly _rootScopeName;
350
+ private readonly balancedBracketSelectors;
351
+ private readonly _onigLib;
352
+ private _rootId;
353
+ private _lastRuleId;
354
+ private readonly _ruleId2desc;
355
+ private readonly _includedGrammars;
356
+ private readonly _grammarRepository;
357
+ private readonly _grammar;
358
+ private _injections;
359
+ private readonly _basicScopeAttributesProvider;
360
+ private readonly _tokenTypeMatchers;
361
+ get themeProvider(): IThemeProvider;
362
+ constructor(_rootScopeName: ScopeName, grammar: IRawGrammar, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null, grammarRepository: IGrammarRepository & IThemeProvider, _onigLib: IOnigLib);
363
+ dispose(): void;
364
+ createOnigScanner(sources: RegExpString[]): OnigScanner;
365
+ createOnigString(sources: string): OnigString;
366
+ getMetadataForScope(scope: string): BasicScopeAttributes;
367
+ private _collectInjections;
368
+ getInjections(): Injection[];
369
+ registerRule<T extends Rule>(factory: (id: RuleId) => T): T;
370
+ getRule(ruleId: RuleId): Rule;
371
+ getExternalGrammar(scopeName: string, repository?: IRawRepository): IRawGrammar | undefined;
372
+ tokenizeLine(lineText: string, prevState: StateStackImpl | null, timeLimit?: number): ITokenizeLineResult;
373
+ tokenizeLine2(lineText: string, prevState: StateStackImpl | null, timeLimit?: number): ITokenizeLineResult2;
374
+ private _tokenize;
375
+ }
376
+ declare class AttributedScopeStack {
377
+ readonly parent: AttributedScopeStack | null;
378
+ readonly scopePath: ScopeStack;
379
+ readonly tokenAttributes: EncodedTokenAttributes;
380
+ static fromExtension(namesScopeList: AttributedScopeStack | null, contentNameScopesList: AttributedScopeStackFrame[]): AttributedScopeStack | null;
381
+ static createRoot(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes): AttributedScopeStack;
382
+ static createRootAndLookUpScopeName(scopeName: ScopeName, tokenAttributes: EncodedTokenAttributes, grammar: Grammar): AttributedScopeStack;
383
+ get scopeName(): ScopeName;
384
+ /**
385
+ * Invariant:
386
+ * ```
387
+ * if (parent && !scopePath.extends(parent.scopePath)) {
388
+ * throw new Error();
389
+ * }
390
+ * ```
391
+ */
392
+ private constructor();
393
+ toString(): string;
394
+ equals(other: AttributedScopeStack): boolean;
395
+ static equals(a: AttributedScopeStack | null, b: AttributedScopeStack | null): boolean;
396
+ private static mergeAttributes;
397
+ pushAttributed(scopePath: ScopePath | null, grammar: Grammar): AttributedScopeStack;
398
+ private static _pushAttributed;
399
+ getScopeNames(): string[];
400
+ getExtensionIfDefined(base: AttributedScopeStack | null): AttributedScopeStackFrame[] | undefined;
401
+ }
402
+ interface AttributedScopeStackFrame {
403
+ encodedTokenAttributes: number;
404
+ scopeNames: string[];
405
+ }
406
+ /**
407
+ * Represents a "pushed" state on the stack (as a linked list element).
408
+ */
409
+ declare class StateStackImpl implements StateStack {
410
+ /**
411
+ * The previous state on the stack (or null for the root state).
412
+ */
413
+ readonly parent: StateStackImpl | null;
414
+ /**
415
+ * The state (rule) that this element represents.
416
+ */
417
+ private readonly ruleId;
418
+ /**
419
+ * The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
420
+ */
421
+ readonly beginRuleCapturedEOL: boolean;
422
+ /**
423
+ * The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
424
+ */
425
+ readonly endRule: string | null;
426
+ /**
427
+ * The list of scopes containing the "name" for this state.
428
+ */
429
+ readonly nameScopesList: AttributedScopeStack | null;
430
+ /**
431
+ * The list of scopes containing the "contentName" (besides "name") for this state.
432
+ * This list **must** contain as an element `scopeName`.
433
+ */
434
+ readonly contentNameScopesList: AttributedScopeStack | null;
435
+ _stackElementBrand: void;
436
+ static NULL: StateStackImpl;
437
+ /**
438
+ * The position on the current line where this state was pushed.
439
+ * This is relevant only while tokenizing a line, to detect endless loops.
440
+ * Its value is meaningless across lines.
441
+ */
442
+ private _enterPos;
443
+ /**
444
+ * The captured anchor position when this stack element was pushed.
445
+ * This is relevant only while tokenizing a line, to restore the anchor position when popping.
446
+ * Its value is meaningless across lines.
447
+ */
448
+ private _anchorPos;
449
+ /**
450
+ * The depth of the stack.
451
+ */
452
+ readonly depth: number;
453
+ /**
454
+ * Invariant:
455
+ * ```
456
+ * if (contentNameScopesList !== nameScopesList && contentNameScopesList?.parent !== nameScopesList) {
457
+ * throw new Error();
458
+ * }
459
+ * if (this.parent && !nameScopesList.extends(this.parent.contentNameScopesList)) {
460
+ * throw new Error();
461
+ * }
462
+ * ```
463
+ */
464
+ constructor(
465
+ /**
466
+ * The previous state on the stack (or null for the root state).
467
+ */
468
+ parent: StateStackImpl | null,
469
+ /**
470
+ * The state (rule) that this element represents.
471
+ */
472
+ ruleId: RuleId, enterPos: number, anchorPos: number,
473
+ /**
474
+ * The state has entered and captured \n. This means that the next line should have an anchorPosition of 0.
475
+ */
476
+ beginRuleCapturedEOL: boolean,
477
+ /**
478
+ * The "pop" (end) condition for this state in case that it was dynamically generated through captured text.
479
+ */
480
+ endRule: string | null,
481
+ /**
482
+ * The list of scopes containing the "name" for this state.
483
+ */
484
+ nameScopesList: AttributedScopeStack | null,
485
+ /**
486
+ * The list of scopes containing the "contentName" (besides "name") for this state.
487
+ * This list **must** contain as an element `scopeName`.
488
+ */
489
+ contentNameScopesList: AttributedScopeStack | null);
490
+ equals(other: StateStackImpl): boolean;
491
+ private static _equals;
492
+ /**
493
+ * A structural equals check. Does not take into account `scopes`.
494
+ */
495
+ private static _structuralEquals;
496
+ clone(): StateStackImpl;
497
+ private static _reset;
498
+ reset(): void;
499
+ pop(): StateStackImpl | null;
500
+ safePop(): StateStackImpl;
501
+ push(ruleId: RuleId, enterPos: number, anchorPos: number, beginRuleCapturedEOL: boolean, endRule: string | null, nameScopesList: AttributedScopeStack | null, contentNameScopesList: AttributedScopeStack | null): StateStackImpl;
502
+ getEnterPos(): number;
503
+ getAnchorPos(): number;
504
+ getRule(grammar: IRuleRegistry): Rule;
505
+ toString(): string;
506
+ private _writeString;
507
+ withContentNameScopesList(contentNameScopeStack: AttributedScopeStack): StateStackImpl;
508
+ withEndRule(endRule: string): StateStackImpl;
509
+ hasSameRuleAs(other: StateStackImpl): boolean;
510
+ toStateStackFrame(): StateStackFrame;
511
+ static pushFrame(self: StateStackImpl | null, frame: StateStackFrame): StateStackImpl;
512
+ }
513
+ interface StateStackFrame {
514
+ ruleId: number;
515
+ enterPos?: number;
516
+ anchorPos?: number;
517
+ beginRuleCapturedEOL: boolean;
518
+ endRule: string | null;
519
+ nameScopesList: AttributedScopeStackFrame[];
520
+ /**
521
+ * on top of nameScopesList
522
+ */
523
+ contentNameScopesList: AttributedScopeStackFrame[];
524
+ }
525
+ declare class BalancedBracketSelectors {
526
+ private readonly balancedBracketScopes;
527
+ private readonly unbalancedBracketScopes;
528
+ private allowAny;
529
+ constructor(balancedBracketScopes: string[], unbalancedBracketScopes: string[]);
530
+ get matchesAlways(): boolean;
531
+ get matchesNever(): boolean;
532
+ match(scopes: string[]): boolean;
533
+ }
534
+
535
+ declare class SyncRegistry implements IGrammarRepository, IThemeProvider {
536
+ private readonly _onigLib;
537
+ readonly _grammars: Map<string, Grammar>;
538
+ readonly _rawGrammars: Map<string, IRawGrammar>;
539
+ readonly _injectionGrammars: Map<string, string[]>;
540
+ _theme: Theme;
541
+ constructor(theme: Theme, _onigLib: IOnigLib);
542
+ dispose(): void;
543
+ setTheme(theme: Theme): void;
544
+ getColorMap(): string[];
545
+ /**
546
+ * Add `grammar` to registry and return a list of referenced scope names
547
+ */
548
+ addGrammar(grammar: IRawGrammar, injectionScopeNames?: ScopeName[]): void;
549
+ /**
550
+ * Lookup a raw grammar.
551
+ */
552
+ lookup(scopeName: ScopeName): IRawGrammar | undefined;
553
+ /**
554
+ * Returns the injections for the given grammar
555
+ */
556
+ injections(targetScope: ScopeName): ScopeName[];
557
+ /**
558
+ * Get the default theme settings
559
+ */
560
+ getDefaults(): StyleAttributes;
561
+ /**
562
+ * Match a scope in the theme.
563
+ */
564
+ themeMatch(scopePath: ScopeStack): StyleAttributes | null;
565
+ /**
566
+ * Lookup a grammar.
567
+ */
568
+ grammarForScopeName(scopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap | null, tokenTypes: ITokenTypeMap | null, balancedBracketSelectors: BalancedBracketSelectors | null): IGrammar | null;
569
+ }
570
+
571
+ interface StackDiff {
572
+ readonly pops: number;
573
+ readonly newFrames: StateStackFrame[];
574
+ }
575
+
576
+ /**
577
+ * A registry helper that can locate grammar file paths given scope names.
578
+ */
579
+ interface RegistryOptions {
580
+ onigLib: IOnigLib;
581
+ theme?: IRawTheme;
582
+ colorMap?: string[];
583
+ loadGrammar(scopeName: ScopeName): IRawGrammar | undefined | null;
584
+ getInjections?(scopeName: ScopeName): ScopeName[] | undefined;
585
+ }
586
+ /**
587
+ * A map from scope name to a language id. Please do not use language id 0.
588
+ */
589
+ interface IEmbeddedLanguagesMap {
590
+ [scopeName: string]: number;
591
+ }
592
+ /**
593
+ * A map from selectors to token types.
594
+ */
595
+ interface ITokenTypeMap {
596
+ [selector: string]: StandardTokenType;
597
+ }
598
+ interface IGrammarConfiguration {
599
+ embeddedLanguages?: IEmbeddedLanguagesMap;
600
+ tokenTypes?: ITokenTypeMap;
601
+ balancedBracketSelectors?: string[];
602
+ unbalancedBracketSelectors?: string[];
603
+ }
604
+ /**
605
+ * The registry that will hold all grammars.
606
+ */
607
+ declare class Registry {
608
+ readonly _options: RegistryOptions;
609
+ readonly _syncRegistry: SyncRegistry;
610
+ readonly _ensureGrammarCache: Map<string, boolean>;
611
+ constructor(options: RegistryOptions);
612
+ dispose(): void;
613
+ /**
614
+ * Change the theme. Once called, no previous `ruleStack` should be used anymore.
615
+ */
616
+ setTheme(theme: IRawTheme, colorMap?: string[]): void;
617
+ /**
618
+ * Returns a lookup array for color ids.
619
+ */
620
+ getColorMap(): string[];
621
+ /**
622
+ * Load the grammar for `scopeName` and all referenced included grammars asynchronously.
623
+ * Please do not use language id 0.
624
+ */
625
+ loadGrammarWithEmbeddedLanguages(initialScopeName: ScopeName, initialLanguage: number, embeddedLanguages: IEmbeddedLanguagesMap): IGrammar | null;
626
+ /**
627
+ * Load the grammar for `scopeName` and all referenced included grammars asynchronously.
628
+ * Please do not use language id 0.
629
+ */
630
+ loadGrammarWithConfiguration(initialScopeName: ScopeName, initialLanguage: number, configuration: IGrammarConfiguration): IGrammar | null;
631
+ /**
632
+ * Load the grammar for `scopeName` and all referenced included grammars asynchronously.
633
+ */
634
+ loadGrammar(initialScopeName: ScopeName): IGrammar | null;
635
+ private _loadGrammar;
636
+ private _loadSingleGrammar;
637
+ private _doLoadSingleGrammar;
638
+ /**
639
+ * Adds a rawGrammar.
640
+ */
641
+ addGrammar(rawGrammar: IRawGrammar, injections?: string[], initialLanguage?: number, embeddedLanguages?: IEmbeddedLanguagesMap | null): IGrammar;
642
+ /**
643
+ * Get the grammar for `scopeName`. The grammar must first be created via `loadGrammar` or `addGrammar`.
644
+ */
645
+ private _grammarForScopeName;
646
+ }
647
+ /**
648
+ * A grammar
649
+ */
650
+ interface IGrammar {
651
+ /**
652
+ * Tokenize `lineText` using previous line state `prevState`.
653
+ */
654
+ tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult;
655
+ /**
656
+ * Tokenize `lineText` using previous line state `prevState`.
657
+ * The result contains the tokens in binary format, resolved with the following information:
658
+ * - language
659
+ * - token type (regex, string, comment, other)
660
+ * - font style
661
+ * - foreground color
662
+ * - background color
663
+ * e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET`
664
+ */
665
+ tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2;
666
+ }
667
+ interface ITokenizeLineResult {
668
+ readonly tokens: IToken[];
669
+ /**
670
+ * The `prevState` to be passed on to the next line tokenization.
671
+ */
672
+ readonly ruleStack: StateStack;
673
+ /**
674
+ * Did tokenization stop early due to reaching the time limit.
675
+ */
676
+ readonly stoppedEarly: boolean;
677
+ }
678
+ interface ITokenizeLineResult2 {
679
+ /**
680
+ * The tokens in binary format. Each token occupies two array indices. For token i:
681
+ * - at offset 2*i => startIndex
682
+ * - at offset 2*i + 1 => metadata
683
+ *
684
+ */
685
+ readonly tokens: Uint32Array;
686
+ /**
687
+ * The `prevState` to be passed on to the next line tokenization.
688
+ */
689
+ readonly ruleStack: StateStack;
690
+ /**
691
+ * Did tokenization stop early due to reaching the time limit.
692
+ */
693
+ readonly stoppedEarly: boolean;
694
+ }
695
+ interface IToken {
696
+ startIndex: number;
697
+ readonly endIndex: number;
698
+ readonly scopes: string[];
699
+ }
700
+ /**
701
+ * **IMPORTANT** - Immutable!
702
+ */
703
+ interface StateStack {
704
+ _stackElementBrand: void;
705
+ readonly depth: number;
706
+ clone(): StateStack;
707
+ equals(other: StateStack): boolean;
708
+ }
709
+ declare const INITIAL: StateStack;
710
+
711
+ export { EncodedTokenMetadata, FindOption, FontStyle, type IEmbeddedLanguagesMap, type IGrammar, type IGrammarConfiguration, INITIAL, type IOnigCaptureIndex, type IOnigLib, type IOnigMatch, type IRawGrammar, type IRawTheme, type IRawThemeSetting, type IToken, type ITokenTypeMap, type ITokenizeLineResult, type ITokenizeLineResult2, type OnigScanner, type OnigString, Registry, type RegistryOptions, type StackDiff, type StateStack, StateStackImpl, Theme, disposeOnigString };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shiki",
3
3
  "type": "module",
4
- "version": "2.4.1",
4
+ "version": "2.5.0",
5
5
  "description": "A beautiful Syntax Highlighter.",
6
6
  "author": "Pine Wu <octref@gmail.com>; Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -119,12 +119,12 @@
119
119
  "dependencies": {
120
120
  "@shikijs/vscode-textmate": "^10.0.2",
121
121
  "@types/hast": "^3.0.4",
122
- "@shikijs/core": "2.4.1",
123
- "@shikijs/langs": "2.4.1",
124
- "@shikijs/engine-oniguruma": "2.4.1",
125
- "@shikijs/types": "2.4.1",
126
- "@shikijs/themes": "2.4.1",
127
- "@shikijs/engine-javascript": "2.4.1"
122
+ "@shikijs/core": "2.5.0",
123
+ "@shikijs/engine-oniguruma": "2.5.0",
124
+ "@shikijs/engine-javascript": "2.5.0",
125
+ "@shikijs/themes": "2.5.0",
126
+ "@shikijs/langs": "2.5.0",
127
+ "@shikijs/types": "2.5.0"
128
128
  },
129
129
  "devDependencies": {
130
130
  "rollup-plugin-copy": "^3.5.0",