@shikijs/types 1.21.1 → 1.22.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.
- package/dist/index.d.mts +23 -3
- package/dist/index.d.ts +23 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Element, Root } from 'hast';
|
|
2
|
-
import { OnigScanner, OnigString, IGrammar, IRawGrammar, IRawTheme, IRawThemeSetting, FontStyle } from '@shikijs/vscode-textmate';
|
|
2
|
+
import { OnigScanner, OnigString, IGrammar, IRawGrammar, IRawTheme, IRawThemeSetting, StateStack, FontStyle } from '@shikijs/vscode-textmate';
|
|
3
3
|
export { IRawGrammar as RawGrammar, IRawTheme as RawTheme, IRawThemeSetting as RawThemeSetting } from '@shikijs/vscode-textmate';
|
|
4
4
|
|
|
5
5
|
type Awaitable<T> = T | Promise<T>;
|
|
@@ -237,6 +237,15 @@ interface BundledThemeInfo {
|
|
|
237
237
|
interface GrammarState {
|
|
238
238
|
readonly lang: string;
|
|
239
239
|
readonly theme: string;
|
|
240
|
+
readonly themes: string[];
|
|
241
|
+
/**
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
getInternalStack: (theme?: string) => StateStack | undefined;
|
|
245
|
+
getScopes: (theme?: string) => string[] | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Use `getScopes` instead.
|
|
248
|
+
*/
|
|
240
249
|
get scopes(): string[];
|
|
241
250
|
}
|
|
242
251
|
interface CodeToTokensBaseOptions<Languages extends string = string, Themes extends string = string> extends TokenizeWithThemeOptions {
|
|
@@ -443,6 +452,10 @@ interface TokensResult {
|
|
|
443
452
|
* When specified, `fg` and `bg` will be ignored.
|
|
444
453
|
*/
|
|
445
454
|
rootStyle?: string;
|
|
455
|
+
/**
|
|
456
|
+
* The last grammar state of the code snippet.
|
|
457
|
+
*/
|
|
458
|
+
grammarState?: GrammarState;
|
|
446
459
|
}
|
|
447
460
|
|
|
448
461
|
interface TransformerOptions {
|
|
@@ -686,6 +699,10 @@ interface CodeToHastRenderOptionsCommon extends TransformerOptions, Omit<TokensR
|
|
|
686
699
|
}
|
|
687
700
|
type CodeToHastRenderOptions = CodeToHastRenderOptionsCommon & CodeToHastOptions;
|
|
688
701
|
|
|
702
|
+
/**
|
|
703
|
+
* Type of object that can be bound to a grammar state
|
|
704
|
+
*/
|
|
705
|
+
type GrammarStateMapKey = Root | ThemedToken[][];
|
|
689
706
|
/**
|
|
690
707
|
* Internal context of Shiki, core textmate logic
|
|
691
708
|
*/
|
|
@@ -777,7 +794,10 @@ interface HighlighterGeneric<BundledLangKeys extends string, BundledThemeKeys ex
|
|
|
777
794
|
* Get the last grammar state of a code snippet.
|
|
778
795
|
* You can pass the grammar state to `codeToTokens` as `grammarState` to continue tokenizing from an intermediate state.
|
|
779
796
|
*/
|
|
780
|
-
getLastGrammarState:
|
|
797
|
+
getLastGrammarState: {
|
|
798
|
+
(element: GrammarStateMapKey, options?: never): GrammarState | undefined;
|
|
799
|
+
(code: string, options: CodeToTokensBaseOptions<ResolveBundleKey<BundledLangKeys>, ResolveBundleKey<BundledThemeKeys>>): GrammarState;
|
|
800
|
+
};
|
|
781
801
|
/**
|
|
782
802
|
* Get internal context object
|
|
783
803
|
* @internal
|
|
@@ -804,4 +824,4 @@ declare class ShikiError extends Error {
|
|
|
804
824
|
constructor(message: string);
|
|
805
825
|
}
|
|
806
826
|
|
|
807
|
-
export { type AnsiLanguage, type 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 CreateHighlighterFactory, type CreatedBundledHighlighterOptions, type DecorationItem, type DecorationOptions, type DecorationTransformType, type DynamicImportLanguageRegistration, type DynamicImportThemeRegistration, type Grammar, type GrammarState, type HighlighterCore, type HighlighterCoreOptions, type HighlighterGeneric, type LanguageInput, type LanguageRegistration, type LoadWasmOptions, type LoadWasmOptionsPlain, type MaybeArray, type MaybeGetter, type MaybeModule, type Offset, type OffsetOrPosition, type OnigurumaLoadOptions, type PatternScanner, type PlainTextLanguage, type Position, type RegexEngine, type RegexEngineString, type RequireKeys, type ResolveBundleKey, type ResolvedDecorationItem, type ResolvedPosition, ShikiError, type ShikiInternal, type ShikiTransformer, type ShikiTransformerContext, type ShikiTransformerContextCommon, type ShikiTransformerContextMeta, type ShikiTransformerContextSource, type SpecialLanguage, type SpecialTheme, type 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, type WebAssemblyInstance, type WebAssemblyInstantiator };
|
|
827
|
+
export { type AnsiLanguage, type 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 CreateHighlighterFactory, type CreatedBundledHighlighterOptions, type DecorationItem, type DecorationOptions, type DecorationTransformType, type DynamicImportLanguageRegistration, type DynamicImportThemeRegistration, type Grammar, type GrammarState, type GrammarStateMapKey, type HighlighterCore, type HighlighterCoreOptions, type HighlighterGeneric, type LanguageInput, type LanguageRegistration, type LoadWasmOptions, type LoadWasmOptionsPlain, type MaybeArray, type MaybeGetter, type MaybeModule, type Offset, type OffsetOrPosition, type OnigurumaLoadOptions, type PatternScanner, type PlainTextLanguage, type Position, type RegexEngine, type RegexEngineString, type RequireKeys, type ResolveBundleKey, type ResolvedDecorationItem, type ResolvedPosition, ShikiError, type ShikiInternal, type ShikiTransformer, type ShikiTransformerContext, type ShikiTransformerContextCommon, type ShikiTransformerContextMeta, type ShikiTransformerContextSource, type SpecialLanguage, type SpecialTheme, type 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, type WebAssemblyInstance, type WebAssemblyInstantiator };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Element, Root } from 'hast';
|
|
2
|
-
import { OnigScanner, OnigString, IGrammar, IRawGrammar, IRawTheme, IRawThemeSetting, FontStyle } from '@shikijs/vscode-textmate';
|
|
2
|
+
import { OnigScanner, OnigString, IGrammar, IRawGrammar, IRawTheme, IRawThemeSetting, StateStack, FontStyle } from '@shikijs/vscode-textmate';
|
|
3
3
|
export { IRawGrammar as RawGrammar, IRawTheme as RawTheme, IRawThemeSetting as RawThemeSetting } from '@shikijs/vscode-textmate';
|
|
4
4
|
|
|
5
5
|
type Awaitable<T> = T | Promise<T>;
|
|
@@ -237,6 +237,15 @@ interface BundledThemeInfo {
|
|
|
237
237
|
interface GrammarState {
|
|
238
238
|
readonly lang: string;
|
|
239
239
|
readonly theme: string;
|
|
240
|
+
readonly themes: string[];
|
|
241
|
+
/**
|
|
242
|
+
* @internal
|
|
243
|
+
*/
|
|
244
|
+
getInternalStack: (theme?: string) => StateStack | undefined;
|
|
245
|
+
getScopes: (theme?: string) => string[] | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Use `getScopes` instead.
|
|
248
|
+
*/
|
|
240
249
|
get scopes(): string[];
|
|
241
250
|
}
|
|
242
251
|
interface CodeToTokensBaseOptions<Languages extends string = string, Themes extends string = string> extends TokenizeWithThemeOptions {
|
|
@@ -443,6 +452,10 @@ interface TokensResult {
|
|
|
443
452
|
* When specified, `fg` and `bg` will be ignored.
|
|
444
453
|
*/
|
|
445
454
|
rootStyle?: string;
|
|
455
|
+
/**
|
|
456
|
+
* The last grammar state of the code snippet.
|
|
457
|
+
*/
|
|
458
|
+
grammarState?: GrammarState;
|
|
446
459
|
}
|
|
447
460
|
|
|
448
461
|
interface TransformerOptions {
|
|
@@ -686,6 +699,10 @@ interface CodeToHastRenderOptionsCommon extends TransformerOptions, Omit<TokensR
|
|
|
686
699
|
}
|
|
687
700
|
type CodeToHastRenderOptions = CodeToHastRenderOptionsCommon & CodeToHastOptions;
|
|
688
701
|
|
|
702
|
+
/**
|
|
703
|
+
* Type of object that can be bound to a grammar state
|
|
704
|
+
*/
|
|
705
|
+
type GrammarStateMapKey = Root | ThemedToken[][];
|
|
689
706
|
/**
|
|
690
707
|
* Internal context of Shiki, core textmate logic
|
|
691
708
|
*/
|
|
@@ -777,7 +794,10 @@ interface HighlighterGeneric<BundledLangKeys extends string, BundledThemeKeys ex
|
|
|
777
794
|
* Get the last grammar state of a code snippet.
|
|
778
795
|
* You can pass the grammar state to `codeToTokens` as `grammarState` to continue tokenizing from an intermediate state.
|
|
779
796
|
*/
|
|
780
|
-
getLastGrammarState:
|
|
797
|
+
getLastGrammarState: {
|
|
798
|
+
(element: GrammarStateMapKey, options?: never): GrammarState | undefined;
|
|
799
|
+
(code: string, options: CodeToTokensBaseOptions<ResolveBundleKey<BundledLangKeys>, ResolveBundleKey<BundledThemeKeys>>): GrammarState;
|
|
800
|
+
};
|
|
781
801
|
/**
|
|
782
802
|
* Get internal context object
|
|
783
803
|
* @internal
|
|
@@ -804,4 +824,4 @@ declare class ShikiError extends Error {
|
|
|
804
824
|
constructor(message: string);
|
|
805
825
|
}
|
|
806
826
|
|
|
807
|
-
export { type AnsiLanguage, type 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 CreateHighlighterFactory, type CreatedBundledHighlighterOptions, type DecorationItem, type DecorationOptions, type DecorationTransformType, type DynamicImportLanguageRegistration, type DynamicImportThemeRegistration, type Grammar, type GrammarState, type HighlighterCore, type HighlighterCoreOptions, type HighlighterGeneric, type LanguageInput, type LanguageRegistration, type LoadWasmOptions, type LoadWasmOptionsPlain, type MaybeArray, type MaybeGetter, type MaybeModule, type Offset, type OffsetOrPosition, type OnigurumaLoadOptions, type PatternScanner, type PlainTextLanguage, type Position, type RegexEngine, type RegexEngineString, type RequireKeys, type ResolveBundleKey, type ResolvedDecorationItem, type ResolvedPosition, ShikiError, type ShikiInternal, type ShikiTransformer, type ShikiTransformerContext, type ShikiTransformerContextCommon, type ShikiTransformerContextMeta, type ShikiTransformerContextSource, type SpecialLanguage, type SpecialTheme, type 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, type WebAssemblyInstance, type WebAssemblyInstantiator };
|
|
827
|
+
export { type AnsiLanguage, type 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 CreateHighlighterFactory, type CreatedBundledHighlighterOptions, type DecorationItem, type DecorationOptions, type DecorationTransformType, type DynamicImportLanguageRegistration, type DynamicImportThemeRegistration, type Grammar, type GrammarState, type GrammarStateMapKey, type HighlighterCore, type HighlighterCoreOptions, type HighlighterGeneric, type LanguageInput, type LanguageRegistration, type LoadWasmOptions, type LoadWasmOptionsPlain, type MaybeArray, type MaybeGetter, type MaybeModule, type Offset, type OffsetOrPosition, type OnigurumaLoadOptions, type PatternScanner, type PlainTextLanguage, type Position, type RegexEngine, type RegexEngineString, type RequireKeys, type ResolveBundleKey, type ResolvedDecorationItem, type ResolvedPosition, ShikiError, type ShikiInternal, type ShikiTransformer, type ShikiTransformerContext, type ShikiTransformerContextCommon, type ShikiTransformerContextMeta, type ShikiTransformerContextSource, type SpecialLanguage, type SpecialTheme, type 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, type WebAssemblyInstance, type WebAssemblyInstantiator };
|