Skip to content

Commit

Permalink
fix(compact): improve types export
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Dec 11, 2023
1 parent 02d7b50 commit 5d73792
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion packages/shikiji-compat/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import type {
CodeOptionsMultipleThemes,
CodeOptionsSingleTheme,
CodeToHastOptionsCommon,
IRawGrammar,
LanguageRegistration,
RawGrammar,
StringLiteralUnion,
ThemeRegistration,
ThemeRegistrationRaw,
ThemedToken,
} from 'shikiji'

export interface LineOption {
Expand All @@ -35,6 +36,8 @@ export interface HighlighterOptions extends BundledHighlighterOptions<BuiltinLan
export type IThemeRegistration = ThemeRegistrationRaw | ThemeRegistration | StringLiteralUnion<BuiltinTheme>

export interface IShikiTheme extends ThemeRegistration {}
export interface IThemedToken extends ThemedToken {}
export interface IRawGrammar extends RawGrammar {}

export interface ILanguageRegistration extends LanguageRegistration {
grammar?: IRawGrammar
Expand Down
23 changes: 16 additions & 7 deletions packages/shikiji/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import type { IGrammar, IRawGrammar, IRawTheme } from 'vscode-textmate'
import type {
IGrammar as Grammar,
IRawGrammar as RawGrammar,
IRawTheme as RawTheme,
} from 'vscode-textmate'
import type { IRawThemeSetting } from 'vscode-textmate/release/theme'
import type { Element, Root } from 'hast'
import type { bundledThemes } from './themes'
import type { bundledLanguages } from './assets/langs'
import type { FontStyle } from './core/stackElementMetadata'
import type { OnigurumaLoadOptions } from './oniguruma'

export { IRawGrammar, IGrammar, FontStyle }
export {
Grammar,
RawGrammar,
FontStyle,
// TODO: move these in the next major version
Grammar as IGrammar,
RawGrammar as IRawGrammar,
}

export type BuiltinLanguage = keyof typeof bundledLanguages
export type BuiltinTheme = keyof typeof bundledThemes
Expand Down Expand Up @@ -42,7 +53,7 @@ export interface ShikiContext {
}

getTheme(name: string | ThemeRegistration | ThemeRegistrationRaw): ThemeRegistration
getLangGrammar(name: string): IGrammar
getLangGrammar(name: string): Grammar

getLoadedThemes(): string[]
getLoadedLanguages(): string[]
Expand Down Expand Up @@ -155,7 +166,7 @@ export interface BundledHighlighterOptions<L extends string, T extends string> {
langAlias?: Record<string, StringLiteralUnion<L>>
}

export interface LanguageRegistration extends IRawGrammar {
export interface LanguageRegistration extends RawGrammar {
name: string
scopeName: string
displayName?: string
Expand Down Expand Up @@ -290,9 +301,7 @@ export type CodeToHastOptions<Languages extends string = string, Themes extends
& CodeOptionsThemes<Themes>
& CodeOptionsMeta

export interface ThemeRegistrationRaw extends IRawTheme {

}
export interface ThemeRegistrationRaw extends RawTheme {}

export interface ThemeRegistration extends ThemeRegistrationRaw {
/**
Expand Down

0 comments on commit 5d73792

Please sign in to comment.