@shikijs/core 1.16.0 → 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 +2 -196
- package/dist/index.d.mts +7 -23
- package/dist/index.mjs +5 -3111
- package/dist/types.d.mts +5 -3
- package/dist/wasm-inlined.d.mts +1 -0
- package/package.json +2 -2
package/dist/chunk-engines.d.mts
CHANGED
|
@@ -1,198 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
* Identifiers with a binary dot operator.
|
|
44
|
-
* Examples: `baz` or `foo.bar`
|
|
45
|
-
*/
|
|
46
|
-
type ScopeName = string;
|
|
47
|
-
/**
|
|
48
|
-
* An expression language of ScopePathStr with a binary comma (to indicate alternatives) operator.
|
|
49
|
-
* Examples: `foo.bar boo.baz,quick quack`
|
|
50
|
-
*/
|
|
51
|
-
type ScopePattern = string;
|
|
52
|
-
/**
|
|
53
|
-
* A TextMate theme.
|
|
54
|
-
*/
|
|
55
|
-
interface IRawTheme {
|
|
56
|
-
readonly name?: string;
|
|
57
|
-
readonly settings: IRawThemeSetting[];
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* A single theme setting.
|
|
61
|
-
*/
|
|
62
|
-
interface IRawThemeSetting {
|
|
63
|
-
readonly name?: string;
|
|
64
|
-
readonly scope?: ScopePattern | ScopePattern[];
|
|
65
|
-
readonly settings: {
|
|
66
|
-
readonly fontStyle?: string;
|
|
67
|
-
readonly foreground?: string;
|
|
68
|
-
readonly background?: string;
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
declare const ruleIdSymbol: unique symbol;
|
|
73
|
-
type RuleId = {
|
|
74
|
-
__brand: typeof ruleIdSymbol;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
interface IRawGrammar extends ILocatable {
|
|
78
|
-
repository: IRawRepository;
|
|
79
|
-
readonly scopeName: ScopeName;
|
|
80
|
-
readonly patterns: IRawRule[];
|
|
81
|
-
readonly injections?: {
|
|
82
|
-
[expression: string]: IRawRule;
|
|
83
|
-
};
|
|
84
|
-
readonly injectionSelector?: string;
|
|
85
|
-
readonly fileTypes?: string[];
|
|
86
|
-
readonly name?: string;
|
|
87
|
-
readonly firstLineMatch?: string;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Allowed values:
|
|
91
|
-
* * Scope Name, e.g. `source.ts`
|
|
92
|
-
* * Top level scope reference, e.g. `source.ts#entity.name.class`
|
|
93
|
-
* * Relative scope reference, e.g. `#entity.name.class`
|
|
94
|
-
* * self, e.g. `$self`
|
|
95
|
-
* * base, e.g. `$base`
|
|
96
|
-
*/
|
|
97
|
-
type IncludeString = string;
|
|
98
|
-
type RegExpString = string;
|
|
99
|
-
interface IRawRepositoryMap {
|
|
100
|
-
[name: string]: IRawRule;
|
|
101
|
-
$self: IRawRule;
|
|
102
|
-
$base: IRawRule;
|
|
103
|
-
}
|
|
104
|
-
type IRawRepository = IRawRepositoryMap & ILocatable;
|
|
105
|
-
interface IRawRule extends ILocatable {
|
|
106
|
-
id?: RuleId;
|
|
107
|
-
readonly include?: IncludeString;
|
|
108
|
-
readonly name?: ScopeName;
|
|
109
|
-
readonly contentName?: ScopeName;
|
|
110
|
-
readonly match?: RegExpString;
|
|
111
|
-
readonly captures?: IRawCaptures;
|
|
112
|
-
readonly begin?: RegExpString;
|
|
113
|
-
readonly beginCaptures?: IRawCaptures;
|
|
114
|
-
readonly end?: RegExpString;
|
|
115
|
-
readonly endCaptures?: IRawCaptures;
|
|
116
|
-
readonly while?: RegExpString;
|
|
117
|
-
readonly whileCaptures?: IRawCaptures;
|
|
118
|
-
readonly patterns?: IRawRule[];
|
|
119
|
-
readonly repository?: IRawRepository;
|
|
120
|
-
readonly applyEndPatternLast?: boolean;
|
|
121
|
-
}
|
|
122
|
-
type IRawCaptures = IRawCapturesMap & ILocatable;
|
|
123
|
-
interface IRawCapturesMap {
|
|
124
|
-
[captureId: string]: IRawRule;
|
|
125
|
-
}
|
|
126
|
-
interface ILocation {
|
|
127
|
-
readonly filename: string;
|
|
128
|
-
readonly line: number;
|
|
129
|
-
readonly char: number;
|
|
130
|
-
}
|
|
131
|
-
interface ILocatable {
|
|
132
|
-
readonly $vscodeTextmateLocation?: ILocation;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* A grammar
|
|
136
|
-
*/
|
|
137
|
-
interface IGrammar {
|
|
138
|
-
/**
|
|
139
|
-
* Tokenize `lineText` using previous line state `prevState`.
|
|
140
|
-
*/
|
|
141
|
-
tokenizeLine(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult;
|
|
142
|
-
/**
|
|
143
|
-
* Tokenize `lineText` using previous line state `prevState`.
|
|
144
|
-
* The result contains the tokens in binary format, resolved with the following information:
|
|
145
|
-
* - language
|
|
146
|
-
* - token type (regex, string, comment, other)
|
|
147
|
-
* - font style
|
|
148
|
-
* - foreground color
|
|
149
|
-
* - background color
|
|
150
|
-
* e.g. for getting the languageId: `(metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET`
|
|
151
|
-
*/
|
|
152
|
-
tokenizeLine2(lineText: string, prevState: StateStack | null, timeLimit?: number): ITokenizeLineResult2;
|
|
153
|
-
}
|
|
154
|
-
interface ITokenizeLineResult {
|
|
155
|
-
readonly tokens: IToken[];
|
|
156
|
-
/**
|
|
157
|
-
* The `prevState` to be passed on to the next line tokenization.
|
|
158
|
-
*/
|
|
159
|
-
readonly ruleStack: StateStack;
|
|
160
|
-
/**
|
|
161
|
-
* Did tokenization stop early due to reaching the time limit.
|
|
162
|
-
*/
|
|
163
|
-
readonly stoppedEarly: boolean;
|
|
164
|
-
}
|
|
165
|
-
interface ITokenizeLineResult2 {
|
|
166
|
-
/**
|
|
167
|
-
* The tokens in binary format. Each token occupies two array indices. For token i:
|
|
168
|
-
* - at offset 2*i => startIndex
|
|
169
|
-
* - at offset 2*i + 1 => metadata
|
|
170
|
-
*
|
|
171
|
-
*/
|
|
172
|
-
readonly tokens: Uint32Array;
|
|
173
|
-
/**
|
|
174
|
-
* The `prevState` to be passed on to the next line tokenization.
|
|
175
|
-
*/
|
|
176
|
-
readonly ruleStack: StateStack;
|
|
177
|
-
/**
|
|
178
|
-
* Did tokenization stop early due to reaching the time limit.
|
|
179
|
-
*/
|
|
180
|
-
readonly stoppedEarly: boolean;
|
|
181
|
-
}
|
|
182
|
-
interface IToken {
|
|
183
|
-
startIndex: number;
|
|
184
|
-
readonly endIndex: number;
|
|
185
|
-
readonly scopes: string[];
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* **IMPORTANT** - Immutable!
|
|
189
|
-
*/
|
|
190
|
-
interface StateStack {
|
|
191
|
-
_stackElementBrand: void;
|
|
192
|
-
readonly depth: number;
|
|
193
|
-
clone(): StateStack;
|
|
194
|
-
equals(other: StateStack): boolean;
|
|
195
|
-
}
|
|
1
|
+
import { OnigScanner, OnigString } from '@shikijs/vscode-textmate';
|
|
196
2
|
|
|
197
3
|
type Awaitable<T> = T | Promise<T>;
|
|
198
4
|
type MaybeGetter<T> = Awaitable<MaybeModule<T>> | (() => Awaitable<MaybeModule<T>>);
|
|
@@ -245,4 +51,4 @@ interface JavaScriptRegexEngineOptions {
|
|
|
245
51
|
cache?: Map<string, RegExp | Error>;
|
|
246
52
|
}
|
|
247
53
|
|
|
248
|
-
export type { Awaitable as A,
|
|
54
|
+
export type { Awaitable as A, JavaScriptRegexEngineOptions as J, LoadWasmOptions as L, MaybeArray as M, OnigurumaLoadOptions as O, PatternScanner as P, RequireKeys as R, StringLiteralUnion as S, WebAssemblyInstantiator as W, RegexEngine as a, MaybeGetter as b, MaybeModule as c, RegexEngineString as d, WebAssemblyInstance as e, LoadWasmOptionsPlain as f };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { HighlighterCoreOptions, HighlighterCore, BundledHighlighterOptions, HighlighterGeneric, CreatedBundledHighlighterOptions, LanguageInput, ThemeInput, CodeToHastOptions, CodeToTokensOptions, TokensResult, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, GrammarState, ShikiInternal,
|
|
2
|
-
export { AnsiLanguage, BundledLanguageInfo, BundledThemeInfo, CodeOptionsMeta, CodeOptionsMultipleThemes, CodeOptionsSingleTheme, CodeOptionsThemes, CodeToHastOptionsCommon, CodeToHastRenderOptionsCommon, DecorationItem, DecorationOptions, DecorationTransformType, DynamicImportLanguageRegistration, DynamicImportThemeRegistration, Grammar, LanguageRegistration, Offset, OffsetOrPosition, ResolveBundleKey, ResolvedDecorationItem, ResolvedPosition, ShikiTransformerContext, ShikiTransformerContextMeta, ThemeRegistration, ThemeRegistrationRaw, ThemedTokenExplanation, ThemedTokenScopeExplanation, TokenBase, TransformerOptions } from './types.mjs';
|
|
3
|
-
import { R as RequireKeys, L as LoadWasmOptions, a as RegexEngine, J as JavaScriptRegexEngineOptions,
|
|
4
|
-
export { A as Awaitable,
|
|
1
|
+
import { HighlighterCoreOptions, HighlighterCore, BundledHighlighterOptions, HighlighterGeneric, CreatedBundledHighlighterOptions, LanguageInput, ThemeInput, CodeToHastOptions, CodeToTokensOptions, TokensResult, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, GrammarState, ShikiInternal, ThemeRegistrationAny, ThemeRegistrationResolved, TokenizeWithThemeOptions, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, PlainTextLanguage, SpecialLanguage, SpecialTheme, TokenStyles, Position, ShikiTransformer } from './types.mjs';
|
|
2
|
+
export { AnsiLanguage, BundledLanguageInfo, BundledThemeInfo, CodeOptionsMeta, CodeOptionsMultipleThemes, CodeOptionsSingleTheme, CodeOptionsThemes, CodeToHastOptionsCommon, CodeToHastRenderOptionsCommon, DecorationItem, DecorationOptions, DecorationTransformType, DynamicImportLanguageRegistration, DynamicImportThemeRegistration, FontStyle, Grammar, LanguageRegistration, Offset, OffsetOrPosition, ResolveBundleKey, ResolvedDecorationItem, ResolvedPosition, ShikiTransformerContext, ShikiTransformerContextMeta, ThemeRegistration, ThemeRegistrationRaw, ThemedTokenExplanation, ThemedTokenScopeExplanation, TokenBase, TransformerOptions } from './types.mjs';
|
|
3
|
+
import { R as RequireKeys, L as LoadWasmOptions, a as RegexEngine, J as JavaScriptRegexEngineOptions, M as MaybeArray, b as MaybeGetter } from './chunk-engines.mjs';
|
|
4
|
+
export { A as Awaitable, f as LoadWasmOptionsPlain, c as MaybeModule, O as OnigurumaLoadOptions, P as PatternScanner, d as RegexEngineString, S as StringLiteralUnion, e as WebAssemblyInstance, W as WebAssemblyInstantiator } from './chunk-engines.mjs';
|
|
5
5
|
import { Root, RootContent, Nodes, Element } from 'hast';
|
|
6
|
+
import { IGrammar } from '@shikijs/vscode-textmate';
|
|
7
|
+
export { IRawGrammar as RawGrammar, IRawTheme as RawTheme, IRawThemeSetting as RawThemeSetting, EncodedTokenMetadata as StackElementMetadata } from '@shikijs/vscode-textmate';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* Create a Shiki core highlighter instance, with no languages or themes bundled.
|
|
@@ -140,24 +142,6 @@ declare function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise
|
|
|
140
142
|
*/
|
|
141
143
|
declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
|
|
142
144
|
|
|
143
|
-
declare const enum TemporaryStandardTokenType {
|
|
144
|
-
Other = 0,
|
|
145
|
-
Comment = 1,
|
|
146
|
-
String = 2,
|
|
147
|
-
RegEx = 4,
|
|
148
|
-
MetaEmbedded = 8
|
|
149
|
-
}
|
|
150
|
-
declare class StackElementMetadata {
|
|
151
|
-
static toBinaryStr(metadata: number): string;
|
|
152
|
-
static getLanguageId(metadata: number): number;
|
|
153
|
-
static getTokenType(metadata: number): number;
|
|
154
|
-
static getFontStyle(metadata: number): number;
|
|
155
|
-
static getForeground(metadata: number): number;
|
|
156
|
-
static getBackground(metadata: number): number;
|
|
157
|
-
static containsBalancedBrackets(metadata: number): boolean;
|
|
158
|
-
static set(metadata: number, languageId: number, tokenType: TemporaryStandardTokenType, fontStyle: FontStyle, foreground: number, background: number): number;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
145
|
/**
|
|
162
146
|
* Normalize a textmate theme to shiki theme
|
|
163
147
|
*/
|
|
@@ -486,4 +470,4 @@ declare class ShikiError extends Error {
|
|
|
486
470
|
constructor(message: string);
|
|
487
471
|
}
|
|
488
472
|
|
|
489
|
-
export { BundledHighlighterOptions, CodeToHastOptions, CodeToHastRenderOptions, CodeToTokensBaseOptions, CodeToTokensOptions, CodeToTokensWithThemesOptions, type CreateHighlighterFactory, CreatedBundledHighlighterOptions,
|
|
473
|
+
export { BundledHighlighterOptions, CodeToHastOptions, CodeToHastRenderOptions, CodeToTokensBaseOptions, CodeToTokensOptions, CodeToTokensWithThemesOptions, type CreateHighlighterFactory, CreatedBundledHighlighterOptions, GrammarState, HighlighterCore, HighlighterCoreOptions, HighlighterGeneric, JavaScriptRegexEngineOptions, LanguageInput, LoadWasmOptions, MaybeArray, MaybeGetter, PlainTextLanguage, Position, RegexEngine, RequireKeys, ShikiError, ShikiInternal, ShikiTransformer, ShikiTransformerContextCommon, ShikiTransformerContextSource, type ShorthandsBundle, SpecialLanguage, SpecialTheme, ThemeInput, ThemeRegistrationAny, ThemeRegistrationResolved, ThemedToken, ThemedTokenWithVariants, TokenStyles, TokenizeWithThemeOptions, TokensResult, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, toHtml as hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, setDefaultWasmLoader, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations };
|