import type { Language as Language_2 } from 'web-tree-sitter'; import type { Node as Node_2 } from 'web-tree-sitter'; import type { Parser } from 'web-tree-sitter'; import type { Query } from 'web-tree-sitter'; import type { Range as Range_2 } from 'web-tree-sitter'; /** ANSI reset escape sequence. */ declare const ANSI_RESET = "\u001B[0m"; export { ANSI_RESET } export { ANSI_RESET as ANSI_RESET_alias_1 } /** A rendered ANSI segment paired with its byte range. */ export declare type AnsiSegment = [string, HighlightRange]; /** * Append a text fragment to the last line, splitting on newlines. * * ```ts * const lines = ['hello'] * appendFragment(lines, ' world\nnew line') * // lines → ['hello world', 'new line'] * ``` * @internal */ export declare function appendFragment(lines: string[], fragment: string): void; export declare function appendThemeCssVars(cssVars: string[], prefix: string, themes: Record, scope: string, language: LanguageRef, excludeTheme?: string): void; /** * Applies `#offset!` to a range. * * Neovim applies the deltas to UTF-8 byte columns. Lumis also requires both * adjusted endpoints to remain valid UTF-8 boundaries and inside the document; * otherwise it keeps the capture's original range. */ export declare function applyCaptureOffset(range: Range_2, offset: QueryCaptureOffset | undefined, maps: SourceMaps): Range_2; /** * Render an `HtmlAttrs` map to an HTML attribute string. * * ```ts * attrsToString({ class: 'foo', style: 'color: red', hidden: true }) * // 'class="foo" style="color: red" hidden' * ``` */ export declare function attrsToString(attrs: HtmlAttrs): string; /** {@inheritDoc node.availableLanguages} */ declare function availableLanguages(...args: Parameters): LanguageInfo[]; export { availableLanguages } export { availableLanguages as availableLanguages_alias_2 } /** * List all supported languages with their ID, name, aliases, and file extensions. * * ```ts * import { availableLanguages } from '@lumis-sh/lumis' * const languages = availableLanguages() * // [{ id: 'javascript', name: 'JavaScript', aliases: ['js', 'jsx'], extensions: ['*.js', ...] }, ...] * ``` */ declare function availableLanguages_2(...args: Parameters): LanguageInfo[]; export { availableLanguages_2 as availableLanguages_alias_1 } export { availableLanguages_2 as availableLanguages_alias_3 } /** * List all built-in themes with their name and appearance. * * ```ts * import { availableThemes } from '@lumis-sh/lumis' * const themes = availableThemes() * // [{ name: 'dracula', appearance: 'dark' }, ...] * ``` */ declare function availableThemes(): ThemeInfo[]; export { availableThemes } export { availableThemes as availableThemes_alias_1 } export { availableThemes as availableThemes_alias_2 } /** * Create a BBCode scoped formatter using highlight scope names as nested tags. * It does not emit standard forum-style BBCode like `[b]`, `[color]`, or `[code]`. * * @example * ```ts * import { bbcodeScoped } from '@lumis-sh/lumis/formatters' * import javascript from '@lumis-sh/lumis/langs/javascript' * * const output = hl.highlight('const x = 1', bbcodeScoped({ language: javascript })) * console.log(output) * ``` */ declare function bbcodeScoped(options?: BBCodeScopedOptions): BBCodeScopedFormatter; export { bbcodeScoped } export { bbcodeScoped as bbcodeScoped_alias_1 } declare interface BBCodeScopedFormatter extends Formatter, BBCodeScopedOptions { } export { BBCodeScopedFormatter } export { BBCodeScopedFormatter as BBCodeScopedFormatter_alias_1 } export { BBCodeScopedFormatter as BBCodeScopedFormatter_alias_2 } /** * Options for {@link bbcodeScoped}. * * ```ts * bbcodeScoped({ language: javascript }) * ``` */ declare interface BBCodeScopedOptions { language?: LanguageRef; rainbowBrackets?: boolean; } export { BBCodeScopedOptions } export { BBCodeScopedOptions as BBCodeScopedOptions_alias_1 } export { BBCodeScopedOptions as BBCodeScopedOptions_alias_2 } export declare const browserResolverOptions: CreateHighlighterOptions; export declare const browserRuntime: RuntimeEnvironment; export declare function buildHighlightEvents(source: string, language: LoadedLanguage, runtime: RuntimeLookup, options?: { rainbowBrackets?: boolean; }): HighlightEvent[]; export declare function buildLineStartMap(source: string): number[]; export declare function buildNormalThemeVars(styles: string[], prefix: string, themes: Record, excludeTheme?: string): void; export declare function buildPreThemeStyle(options: { themes: Record; defaultTheme?: string; cssVariablePrefix?: string; }): string | undefined; export declare function buildSourceMaps(source: string): SourceMaps; export declare const BUILTIN_FORMATTER: unique symbol; declare type BuiltinFormatter = (HtmlInlineFormatter & { [BUILTIN_FORMATTER]: "html-inline"; }) | (HtmlLinkedFormatter & { [BUILTIN_FORMATTER]: "html-linked"; }) | (HtmlMultiThemesFormatter & { [BUILTIN_FORMATTER]: "html-multi-themes"; }) | (BBCodeScopedFormatter & { [BUILTIN_FORMATTER]: "bbcode-scoped"; }) | (TerminalFormatter & { [BUILTIN_FORMATTER]: "terminal"; }); export declare type BuiltinFormatterKind = "html-inline" | "html-linked" | "html-multi-themes" | "bbcode-scoped" | "terminal"; export declare function builtinFormatterKind(formatter: Formatter): BuiltinFormatterKind | undefined; export declare const bundledLanguages: LanguageBundle; export declare const bundledLanguages_alias_1: LanguageBundle; export declare const bundledLanguages_alias_2: LanguageBundle; export declare const bundledLanguages_alias_3: LanguageBundle; export declare const bundledLanguages_alias_4: LanguageBundle; export declare const BUNDLES: Record; export declare interface CachedLanguage { language: string; path: string; downloaded: boolean; wasm: WasmRef; } /** @internal */ export declare function cacheKey(ref: WasmRef): string; /** * Resolve compatible packages and cache exact, integrity-pinned parser WASMs. * When the native Node addon is available, also compile and validate every * selected language and persist its Wasmtime module in the same directory. * * Accepts language names and `bundle-` tokens, the same set * `Lumis.Languages.cache/2` and `lumis languages cache` accept. * * Point `LUMIS_DATA_DIR` at the same directory in the deployed process. */ export declare function cacheLanguages(names: Iterable, options?: CacheLanguagesOptions): Promise; export declare interface CacheLanguagesOptions { /** Destination for verified parsers and native compiled modules. */ directory?: string; /** Resolve the compatible package range again and replace verified parser files. */ force?: boolean; /** Override the exact-version jsDelivr resolver. */ resolver?: WasmResolver; /** Override the compatible-range language-package metadata resolver. */ languagePackageResolver?: LanguagePackageResolver; } export declare interface CaptureMetadata { highlightScope?: string; isInjectionContent: boolean; isInjectionLanguage: boolean; isLocalScope: boolean; isLocalDefinition: boolean; isLocalDefinitionValue: boolean; isLocalReference: boolean; } /** Tried in order; both serve the same `@/` layout. */ export declare const CDNS: readonly ["https://cdn.jsdelivr.net/npm", "https://unpkg.com"]; export declare function cloneLanguageInfo(language: LanguageInfo): LanguageInfo; export declare function cloneThemeInfo(theme: ThemeInfo): ThemeInfo; /** * Close a `` tag. * * ```ts * closeCodeTag() // "" * ``` */ export declare function closeCodeTag(): string; /** * Close a `
` tag.
 *
 * ```ts
 * closePreTag()  // "
" * ``` */ export declare function closePreTag(): string; /** * Build a closing HTML tag. * * ```ts * closeTag('span') // "" * ``` */ export declare function closeTag(name: string): string; /** * Close both `` and `` tags. * * ```ts * closingTags() // "" * ``` */ export declare function closingTags(): string; export declare interface CompiledBracketConfig { query: Query; captureMetadata: Record; rainbowExcludePatterns: boolean[]; } export declare interface CompiledHighlightConfig { query: Query; injectionPatternEnd: number; localsPatternEnd: number; captureMetadata: Record; nonLocalVariablePatterns: boolean[]; /** Per pattern index, the `#offset!` deltas keyed by capture name. */ captureOffsets: Array | undefined>; } export declare function compileHighlightConfig(language: Language_2, Query: typeof Query, highlightsQuery: string, injectionsQuery?: string, localsQuery?: string): CompiledHighlightConfig; declare function configureLanguagePackageResolver(...args: Parameters): void; export { configureLanguagePackageResolver } export { configureLanguagePackageResolver as configureLanguagePackageResolver_alias_2 } declare function configureLanguagePackageResolver_2(fn: LanguagePackageResolver): void; export { configureLanguagePackageResolver_2 as configureLanguagePackageResolver_alias_1 } export { configureLanguagePackageResolver_2 as configureLanguagePackageResolver_alias_3 } /** {@inheritDoc node.configureWasmResolver} */ declare function configureWasmResolver(...args: Parameters): void; export { configureWasmResolver } export { configureWasmResolver as configureWasmResolver_alias_2 } /** * Set a custom WASM resolver for parser binaries. Applies globally. * * ```ts * import { configureWasmResolver } from '@lumis-sh/lumis' * * configureWasmResolver((_language, wasm) => * `https://unpkg.com/${wasm.packageName}@${wasm.version}/${wasm.name}.wasm` * ) * ``` */ declare function configureWasmResolver_2(fn: WasmResolver): void; export { configureWasmResolver_2 as configureWasmResolver_alias_1 } export { configureWasmResolver_2 as configureWasmResolver_alias_3 } /** {@inheritDoc index.createHighlighter} */ export declare function createHighlighter(...args: Parameters): Promise; /** * Create a reusable highlighter with languages loaded during setup. * * `createHighlighter` is async; the returned `hl.highlight()` is synchronous. * * The `languages` array accepts `Language` objects, `LanguageBundle` collections, and dynamic imports. * * @example Cherry-pick languages * ```ts * import { createHighlighter } from '@lumis-sh/lumis' * import { htmlInline } from '@lumis-sh/lumis/formatters' * import javascript from '@lumis-sh/lumis/langs/javascript' * import dracula from '@lumis-sh/themes/dracula' * * const hl = await createHighlighter({ languages: [javascript] }) * const html = hl.highlight('const x = 1', htmlInline({ language: javascript, theme: dracula })) * ``` * * @example With a bundle * ```ts * import { createHighlighter } from '@lumis-sh/lumis' * import { htmlInline } from '@lumis-sh/lumis/formatters' * import { bundledLanguages } from '@lumis-sh/lumis/bundles/web' * import dracula from '@lumis-sh/themes/dracula' * * // Register all web languages. None are loaded yet. * const hl = await createHighlighter({ languages: [bundledLanguages] }) * * // Load a language, then highlight synchronously. * await hl.loadLanguage(bundledLanguages.javascript) * const html = hl.highlight('const x = 1', htmlInline({ language: bundledLanguages.javascript, theme: dracula })) * ``` */ export declare function createHighlighter_alias_1(...args: Parameters): Promise; export declare function createHighlighterModule(factory: HighlighterModuleFactory): { createHighlighter(init?: CreateHighlighterOptions): Promise; highlight(source: string, fmt: Formatter): Promise; }; /** Options for {@link createHighlighter}. */ declare interface CreateHighlighterOptions { /** Languages to load during setup or register lazily. */ languages?: LanguageInput[]; /** Optional resolver for external WASM assets. */ wasmResolver?: WasmResolver; /** Optional resolver for self-contained language package metadata. */ languagePackageResolver?: LanguagePackageResolver; } export { CreateHighlighterOptions } export { CreateHighlighterOptions as CreateHighlighterOptions_alias_1 } export { CreateHighlighterOptions as CreateHighlighterOptions_alias_2 } export declare function createLanguagesModule(runtime: RuntimeEnvironment): LanguagesModule; export declare function createLoadLanguages(loadLanguage: RuntimeLike["loadLanguage"]): LoadLanguages; /** * Node highlighting over the Wasmtime addon. * * Rust resolves, verifies, caches and loads parsers by default, which is what * lets an injected language load during the walk that finds it. A caller can * still take that over — `configureWasmResolver`, `configureLanguagePackageResolver`, * an explicit `wasm`, or a complete custom `Language` — and those all mean the * same thing here as under `web-tree-sitter`. When one is in play the JavaScript * pipeline in `createLanguagesModule` resolves roots before handing verified * bytes to the addon. During a native walk, the addon reads and verifies the * source locations returned by the same callbacks synchronously. * * `resolvers` is that pipeline: the same module the `web-tree-sitter` runtime * uses, so there is one implementation of resolve, verify and cache rather than * a native copy that can drift. */ export declare function createNativeLanguagesModule(binding: NativeBinding, resolvers: LanguagesModule): LanguagesModule; export declare function createRuntime(...args: Parameters): RuntimeLike; export declare function createRuntime_alias_1(...args: Parameters): RuntimeLike; /** @internal */ /** * Everything Lumis persists lives under one directory, `LUMIS_DATA_DIR`. * * The addon resolves the default through `etcetera`, so asking it rather than * deciding here keeps the Wasm runtime on the store the native runtime, the CLI * and the Elixir NIF already share. {@link platformDataDir} answers only where * no addon is built, and a test pins it against the Rust result. */ export declare function dataDir(): Promise; /** * Decode the compact event stream returned by the native addon. * * Every event starts with a one-byte tag: * - source (0): start byte as u32 LE, end byte as u32 LE * - start (1): scope index as u16 LE, language byte length as u16 LE, UTF-8 language * - end (2): no payload */ export declare function decodeNativeEvents(data: Uint8Array): HighlightEvent_2[]; /** @internal */ export declare function decodeSourceSlice(sourceBytes: Uint8Array, startByte: number, endByte: number): string; export declare const default_alias: ArrayBuffer; export declare const default_alias_1: LanguagePackageHandle; export declare const default_alias_10: LanguagePackageHandle; export declare const default_alias_100: LanguagePackageHandle; export declare const default_alias_101: LanguagePackageHandle; export declare const default_alias_102: LanguagePackageHandle; export declare const default_alias_103: LanguagePackageHandle; export declare const default_alias_104: LanguagePackageHandle; export declare const default_alias_105: LanguagePackageHandle; export declare const default_alias_106: LanguagePackageHandle; export declare const default_alias_107: LanguagePackageHandle; export declare const default_alias_108: LanguagePackageHandle; export declare const default_alias_109: LanguagePackageHandle; export declare const default_alias_11: LanguagePackageHandle; export declare const default_alias_110: LanguagePackageHandle; export declare const default_alias_111: LanguagePackageHandle; export declare const default_alias_112: LanguagePackageHandle; export declare const default_alias_113: LanguagePackageHandle; export declare const default_alias_114: LanguagePackageHandle; export declare const default_alias_115: LanguagePackageHandle; export declare const default_alias_116: LanguagePackageHandle; export declare const default_alias_12: LanguagePackageHandle; export declare const default_alias_13: LanguagePackageHandle; export declare const default_alias_14: LanguagePackageHandle; export declare const default_alias_15: LanguagePackageHandle; export declare const default_alias_16: LanguagePackageHandle; export declare const default_alias_17: LanguagePackageHandle; export declare const default_alias_18: LanguagePackageHandle; export declare const default_alias_19: LanguagePackageHandle; export declare const default_alias_2: LanguagePackageHandle; export declare const default_alias_20: LanguagePackageHandle; export declare const default_alias_21: LanguagePackageHandle; export declare const default_alias_22: LanguagePackageHandle; export declare const default_alias_23: LanguagePackageHandle; export declare const default_alias_24: LanguagePackageHandle; export declare const default_alias_25: LanguagePackageHandle; export declare const default_alias_26: LanguagePackageHandle; export declare const default_alias_27: LanguagePackageHandle; export declare const default_alias_28: LanguagePackageHandle; export declare const default_alias_29: LanguagePackageHandle; export declare const default_alias_3: LanguagePackageHandle; export declare const default_alias_30: LanguagePackageHandle; export declare const default_alias_31: LanguagePackageHandle; export declare const default_alias_32: LanguagePackageHandle; export declare const default_alias_33: LanguagePackageHandle; export declare const default_alias_34: LanguagePackageHandle; export declare const default_alias_35: LanguagePackageHandle; export declare const default_alias_36: LanguagePackageHandle; export declare const default_alias_37: LanguagePackageHandle; export declare const default_alias_38: LanguagePackageHandle; export declare const default_alias_39: LanguagePackageHandle; export declare const default_alias_4: LanguagePackageHandle; export declare const default_alias_40: LanguagePackageHandle; export declare const default_alias_41: LanguagePackageHandle; export declare const default_alias_42: LanguagePackageHandle; export declare const default_alias_43: LanguagePackageHandle; export declare const default_alias_44: LanguagePackageHandle; export declare const default_alias_45: LanguagePackageHandle; export declare const default_alias_46: LanguagePackageHandle; export declare const default_alias_47: LanguagePackageHandle; export declare const default_alias_48: LanguagePackageHandle; export declare const default_alias_49: LanguagePackageHandle; export declare const default_alias_5: LanguagePackageHandle; export declare const default_alias_50: LanguagePackageHandle; export declare const default_alias_51: LanguagePackageHandle; export declare const default_alias_52: LanguagePackageHandle; export declare const default_alias_53: LanguagePackageHandle; export declare const default_alias_54: LanguagePackageHandle; export declare const default_alias_55: LanguagePackageHandle; export declare const default_alias_56: LanguagePackageHandle; export declare const default_alias_57: LanguagePackageHandle; export declare const default_alias_58: LanguagePackageHandle; export declare const default_alias_59: LanguagePackageHandle; export declare const default_alias_6: LanguagePackageHandle; export declare const default_alias_60: LanguagePackageHandle; export declare const default_alias_61: LanguagePackageHandle; export declare const default_alias_62: LanguagePackageHandle; export declare const default_alias_63: LanguagePackageHandle; export declare const default_alias_64: LanguagePackageHandle; export declare const default_alias_65: LanguagePackageHandle; export declare const default_alias_66: LanguagePackageHandle; export declare const default_alias_67: LanguagePackageHandle; export declare const default_alias_68: LanguagePackageHandle; export declare const default_alias_69: LanguagePackageHandle; export declare const default_alias_7: LanguagePackageHandle; export declare const default_alias_70: LanguagePackageHandle; export declare const default_alias_71: LanguagePackageHandle; export declare const default_alias_72: LanguagePackageHandle; export declare const default_alias_73: LanguagePackageHandle; export declare const default_alias_74: LanguagePackageHandle; export declare const default_alias_75: LanguagePackageHandle; export declare const default_alias_76: LanguagePackageHandle; export declare const default_alias_77: LanguagePackageHandle; export declare const default_alias_78: LanguagePackageHandle; export declare const default_alias_79: PlaintextLanguage; export declare const default_alias_8: LanguagePackageHandle; export declare const default_alias_80: LanguagePackageHandle; export declare const default_alias_81: LanguagePackageHandle; export declare const default_alias_82: LanguagePackageHandle; export declare const default_alias_83: LanguagePackageHandle; export declare const default_alias_84: LanguagePackageHandle; export declare const default_alias_85: LanguagePackageHandle; export declare const default_alias_86: LanguagePackageHandle; export declare const default_alias_87: LanguagePackageHandle; export declare const default_alias_88: LanguagePackageHandle; export declare const default_alias_89: LanguagePackageHandle; export declare const default_alias_9: LanguagePackageHandle; export declare const default_alias_90: LanguagePackageHandle; export declare const default_alias_91: LanguagePackageHandle; export declare const default_alias_92: LanguagePackageHandle; export declare const default_alias_93: LanguagePackageHandle; export declare const default_alias_94: LanguagePackageHandle; export declare const default_alias_95: LanguagePackageHandle; export declare const default_alias_96: LanguagePackageHandle; export declare const default_alias_97: LanguagePackageHandle; export declare const default_alias_98: LanguagePackageHandle; export declare const default_alias_99: LanguagePackageHandle; export declare const DEFAULT_LANGUAGE_PACKAGE_RESOLVER: LanguagePackageResolver; /** @internal */ export declare const DEFAULT_RESOLVER: WasmResolver; export declare const EMACS_MODE_MAP: Record; /** @internal */ export declare function encodeSource(source: string): Uint8Array; /** * Escape HTML special characters. * * ```ts * escape('
') * // "<div class="a">" * ``` */ declare function escape_2(text: string): string; export { escape_2 as escape } /** * Escape a string for use inside an HTML attribute value. * * ```ts * escapeAttr('font-size: 14px; color: "red"') * // "font-size: 14px; color: "red"" * ``` */ export declare function escapeAttr(value: string): string; /** * Escape curly braces to HTML entities. * * ```ts * escapeBraces('{foo}') // "{foo}" * ``` */ export declare function escapeBraces(text: string): string; export declare function escapeFragment(text: string): string; export declare const EXACT_LANGUAGE_MAP: Record; /** * Expand every `bundle-` token into its members, leaving other names * alone. Mirrors `catalog::expand_bundles` in `lumis-wasm-runtime`. */ declare function expandBundles(names: Iterable): string[]; export { expandBundles } export { expandBundles as expandBundles_alias_1 } export declare interface ExtendedLanguage extends Language { dialect: string; } export declare const extensibleLanguage: ExtendedLanguage; export declare function formatBBCode(source: string, events: HighlightEvent_2[]): string; /** @internal */ export declare function formatHighlightIterLines(source: string, events: HighlightEvent_2[], languageRef: LanguageRef | undefined, theme: Theme | undefined, options: { formatText?: (text: string) => string; openSpan: (span: HighlightSpan, style: HighlightStyle | undefined) => string; closeSpan?: (span: HighlightSpan, style: HighlightStyle | undefined) => string; }): { lines: string[]; language: string; }; export declare function formatHtmlInline(source: string, events: HighlightEvent_2[], formatter: HtmlInlineFormatter): string; export declare function formatHtmlLinked(source: string, events: HighlightEvent_2[], formatter: HtmlLinkedFormatter): string; export declare function formatHtmlMultiThemes(source: string, events: HighlightEvent_2[], formatter: HtmlMultiThemesFormatter): string; /** * A formatter renders highlighted source code into an output string. * * Built-in formatters are created with `htmlInline()`, `htmlLinked()`, etc. * Custom formatters implement the same interface. Inside `format()`, call the * sync free functions `highlightIter` (for flat token callbacks) or * `highlightEvents` (for nested open/close events) imported from * `@lumis-sh/lumis`. * * While `format()` is running, `this.language` is set to the resolved language * after detection, so the formatter can render language-dependent output * (e.g. ``) without re-running detection. * * ```ts * import { highlightIter, type Formatter } from '@lumis-sh/lumis' * * const formatter: Formatter = { * language: javascript, * format(source) { * const parts: string[] = [] * highlightIter(source, this.language, dracula, (text, _lang, _range, scope) => { * parts.push(scope ? `[${scope}] ${text}` : text) * }) * return parts.join('\n') * }, * } * ``` */ declare interface Formatter { language?: LanguageRef; rainbowBrackets?: boolean; format(source: string): string; } export { Formatter } export { Formatter as Formatter_alias_1 } export { Formatter as Formatter_alias_2 } export declare function formatTerminal(source: string, events: HighlightEvent_2[], formatter: TerminalFormatter): string; export declare const generatedPackageHandle: LanguagePackageHandle; export declare const generatedPlaintext: PlaintextLanguage; export declare function getBuiltinFormatter(formatter: Formatter): BuiltinFormatter | undefined; export declare function getDefaultRuntime(...args: Parameters): RuntimeLike; export declare function getDefaultRuntime_alias_1(...args: Parameters): RuntimeLike; /** * Get the CSS class for a highlighted line, or `undefined` if not highlighted. * * ```ts * getHighlightLineClass([1, [3, 5]], 4, 'active') // "active" * getHighlightLineClass([1, [3, 5]], 2, 'active') // undefined * ``` */ export declare function getHighlightLineClass(lines: LineSpec[] | undefined, lineNumber: number, className: string | undefined, defaultClass?: string): string | undefined; export declare function getInjectionRanges(node: Node_2, includeChildren: boolean): Range_2[]; /** * Look one language up by id or alias. * * ```ts * import { getLanguage } from '@lumis-sh/lumis' * getLanguage('js') // { id: 'javascript', name: 'JavaScript', ... } * getLanguage('nope') // undefined * ``` */ declare function getLanguage(nameOrAlias: string): LanguageInfo | undefined; export { getLanguage } export { getLanguage as getLanguage_alias_1 } export { getLanguage as getLanguage_alias_2 } export declare function getLoadedLanguage(...args: Parameters): LoadedLanguage | undefined; export declare function getLoadedLanguage_alias_1(...args: Parameters): LoadedLanguage | undefined; export declare function getLoadedLanguageIds(...args: Parameters): string[]; export declare function getLoadedLanguageIds_alias_1(...args: Parameters): string[]; /** * Look up a scope's style, trying a language-specific scope first. * * ```ts * getScopedThemeStyle(dracula, 'string', 'json') * // tries 'string.json' first, then falls back to 'string' * ``` * @internal */ export declare function getScopedThemeStyle(theme: Theme | undefined, scope: string, language: LanguageRef): HighlightStyle | undefined; /** * Look up a scope's style in a theme, falling back to parent scopes. * * ```ts * getThemeStyle(dracula, 'string.special.regex') * // tries 'string.special.regex', then 'string.special', then 'string' * ``` * @internal */ export declare function getThemeStyle(theme: Theme | undefined, scope: string): HighlightStyle | undefined; export declare const GLOB_MATCHERS: Array<{ id: string; glob: string; }>; /** * Guess a language ID from a language hint, path, extension, or source content. * * The `language` argument can be a language ID, alias, file extension, file name, * or file path. If it cannot be resolved directly, Lumis falls back to content * heuristics such as Emacs mode headers, shebangs, HTML doctype, and XML declarations. */ declare function guessLanguage(language?: string, source?: string): string; export { guessLanguage } export { guessLanguage as guessLanguage_alias_1 } export { guessLanguage as guessLanguage_alias_2 } /** * Parse a hex color string to RGB components. * * ```ts * hexToRgb('#ff79c6') // [255, 121, 198] * hexToRgb('abc') // undefined * ``` */ declare function hexToRgb(hex: string): [number, number, number] | undefined; export { hexToRgb } export { hexToRgb as hexToRgb_alias_1 } /** {@inheritDoc index.highlight} */ export declare function highlight(...args: Parameters): Promise; /** * Highlight code in a single async call. * * Initializes the parser, loads the language, and returns formatted output. * Uses a shared runtime so loaded languages persist across calls. * * For repeated highlighting, prefer {@link createHighlighter} which separates * async setup from synchronous rendering. * * @example * ```ts * import { highlight } from '@lumis-sh/lumis' * import { htmlInline } from '@lumis-sh/lumis/formatters' * import javascript from '@lumis-sh/lumis/langs/javascript' * import dracula from '@lumis-sh/themes/dracula' * * const html = await highlight('const x = 1', htmlInline({ language: javascript, theme: dracula })) * ``` */ export declare function highlight_alias_1(...args: Parameters): Promise; export declare const HIGHLIGHT_NAMES: string[]; /** * Called for each highlighted token in `highlightIter`. * * ```ts * hl.highlightIter(source, javascript, dracula, (text, language, range, scope, style) => { * console.log(`${scope}: ${text}`) * }) * ``` */ declare type HighlightCallback = (text: string, language: string, range: HighlightRange, scope: string, style: HighlightStyle | undefined) => void; export { HighlightCallback } export { HighlightCallback as HighlightCallback_alias_1 } export { HighlightCallback as HighlightCallback_alias_2 } export declare interface HighlightEndEvent { type: "end"; } /** A reusable highlighter with loaded or lazily registered languages. */ declare interface Highlighter { /** Highlight source code synchronously. The language must already be loaded. */ highlight(source: string, formatter: Formatter): string; /** Low-level token iterator. Calls `onToken` for each highlighted span. Languages must already be loaded. */ highlightIter(source: string, language: LanguageRef | undefined, theme: Theme | undefined, onToken: HighlightCallback): void; /** Load a language by object, lazy handle, or string ID from a registered bundle. No-op if already loaded. */ loadLanguage(language: Language | LazyLanguage | string): Promise; /** IDs of languages that have been loaded and are ready to highlight. */ readonly languages: string[]; /** IDs of all languages, including those registered lazily from bundles. */ readonly registeredLanguages: string[]; } export { Highlighter } export { Highlighter as Highlighter_alias_1 } export { Highlighter as Highlighter_alias_2 } declare const highlighter: { createHighlighter(init?: CreateHighlighterOptions): Promise; highlight(source: string, fmt: Formatter): Promise; }; declare const highlighter_2: { createHighlighter(init?: CreateHighlighterOptions): Promise; highlight(source: string, fmt: Formatter): Promise; }; export declare interface HighlighterModuleFactory { createRuntime(options?: { wasmResolver?: WasmResolver; languagePackageResolver?: LanguagePackageResolver; }): RuntimeLike; getDefaultRuntime(): RuntimeLike; } declare interface HighlighterRuntimeOptions { wasmResolver?: WasmResolver; languagePackageResolver?: LanguagePackageResolver; sharedCache?: SharedRuntimeCache; } export { HighlighterRuntimeOptions } export { HighlighterRuntimeOptions as HighlighterRuntimeOptions_alias_1 } export { HighlighterRuntimeOptions as HighlighterRuntimeOptions_alias_2 } export declare type HighlightEvent = HighlightStartEvent | HighlightSourceEvent | HighlightEndEvent; /** * A nested highlight event from tree-sitter. * * Events form a nested structure: a `start` event opens a scope, * `source` events provide text ranges, and `end` closes the scope. * Parent scopes stay open across child scopes (e.g. a `string` scope * wraps injected `tag` scopes inside template literals). */ declare type HighlightEvent_2 = { type: "start"; scope: string; language: string; } | { type: "source"; startByte: number; endByte: number; } | { type: "end"; }; export { HighlightEvent_2 as HighlightEvent_alias_1 } export { HighlightEvent_2 as HighlightEvent_alias_2 } export { HighlightEvent_2 as HighlightEvent_alias_3 } export { HighlightEvent_2 as HighlightEvent_alias_4 } export { HighlightEvent_2 as HighlightEvent_alias_5 } /** * Return the nested highlight event stream for `source`. * * Sync free function usable inside {@link Formatter.format}. Use this when your * formatter needs paired open/close markers around nested scopes (e.g. BBCode * tags) that the flat {@link highlightIter} callback API would lose. */ declare function highlightEvents(source: string, language: LanguageRef | undefined, options?: { rainbowBrackets?: boolean; }): HighlightEvent_2[]; export { highlightEvents } export { highlightEvents as highlightEvents_alias_1 } export { highlightEvents as highlightEvents_alias_2 } /** * Iterate over highlighted tokens for `source`, calling `onToken` for each flat span. * * Sync free function usable inside {@link Formatter.format}. For top-level * (non-formatter) iteration, use `hl.highlightIter` on a {@link Highlighter} * instance instead. */ declare function highlightIter(source: string, language: LanguageRef | undefined, theme: Theme | undefined, onToken: HighlightCallback): void; export { highlightIter } export { highlightIter as highlightIter_alias_1 } export { highlightIter as highlightIter_alias_2 } /** * Signature of the `highlightIter` free function and the `hl.highlightIter` * method on a {@link Highlighter} instance. * * ```ts * highlightIter(source, javascript, dracula, (text, language, range, scope, style) => { * console.log(`${scope}: ${text}`) * }) * ``` */ declare type HighlightIterFn = (source: string, language: LanguageRef | undefined, theme: Theme | undefined, onToken: HighlightCallback) => void; export { HighlightIterFn } export { HighlightIterFn as HighlightIterFn_alias_1 } export { HighlightIterFn as HighlightIterFn_alias_2 } export { HighlightIterFn as HighlightIterFn_alias_3 } export { HighlightIterFn as HighlightIterFn_alias_4 } /** * Highlight source and collect ANSI-wrapped segments. * * ```ts * const segments = [] * highlightIter(source, language, theme, (text, _language, range, _scope, style) => { * segments.push([paint(text, style), range]) * }) * // [["\x1b[0m...const\x1b[0m", { start: 0, end: 5 }], ...] * ``` * * @deprecated Use `highlightIter()` with `paint()` instead. */ export declare function highlightIterWithAnsi(source: string, language: LanguageRef | undefined, theme: Theme | undefined): Promise; /** * Line highlighting for inline and multi-themes formatters. * * ```ts * htmlInline({ highlightLines: { lines: [1, [3, 5]], style: 'theme' } }) * ``` */ declare interface HighlightLinesInline { lines: LineSpec[]; /** * `"theme"` uses the theme's highlight background. Any other string is raw * CSS. `null` emits no inline style at all, for highlighting by class alone. * * Omitting it is the same as `"theme"`. */ style?: string | null; class?: string; } export { HighlightLinesInline } export { HighlightLinesInline as HighlightLinesInline_alias_1 } export { HighlightLinesInline as HighlightLinesInline_alias_2 } /** * Line highlighting for the linked formatter. * * ```ts * htmlLinked({ highlightLines: { lines: [1, [3, 5]], class: 'active' } }) * ``` */ declare interface HighlightLinesLinked { lines: LineSpec[]; /** Defaults to `"l-highlighted"`. */ class?: string; } export { HighlightLinesLinked } export { HighlightLinesLinked as HighlightLinesLinked_alias_1 } export { HighlightLinesLinked as HighlightLinesLinked_alias_2 } /** * Byte offset range of a highlighted token. * * ```ts * const range: HighlightRange = { start: 0, end: 5 } * ``` */ declare interface HighlightRange { start: number; end: number; } export { HighlightRange } export { HighlightRange as HighlightRange_alias_1 } export { HighlightRange as HighlightRange_alias_2 } export { HighlightRange as HighlightRange_alias_3 } export { HighlightRange as HighlightRange_alias_4 } export declare interface HighlightSourceEvent { type: "source"; startByte: number; endByte: number; } /** * A highlighted token's byte range and scope. * * ```ts * // { startByte: 0, endByte: 5, scope: "keyword", language: "javascript" } * ``` */ declare interface HighlightSpan { startByte: number; endByte: number; scope: string; language: string; } export { HighlightSpan } export { HighlightSpan as HighlightSpan_alias_1 } export { HighlightSpan as HighlightSpan_alias_2 } export declare interface HighlightStartEvent { type: "start"; scope: string; language: string; } /** * Visual style for a scope from a theme. * * ```ts * const style: HighlightStyle = { fg: '#ff79c6', italic: true } * ``` */ declare interface HighlightStyle { fg?: string; bg?: string; bold?: boolean; italic?: boolean; underline?: boolean | "solid" | "wavy" | "double" | "dotted" | "dashed" | "undercurl"; strikethrough?: boolean; } export { HighlightStyle } export { HighlightStyle as HighlightStyle_alias_1 } export { HighlightStyle as HighlightStyle_alias_2 } export { HighlightStyle as HighlightStyle_alias_3 } export { HighlightStyle as HighlightStyle_alias_4 } /** HTML attribute map. Values of `undefined`, `null`, or `false` are omitted. */ export declare type HtmlAttrs = Record; /** * Wraps the `
` block with custom HTML.
 *
 * ```ts
 * htmlInline({ header: { openTag: '
', closeTag: '
' } }) * ``` */ declare interface HtmlElement { openTag: string; closeTag: string; } export { HtmlElement } export { HtmlElement as HtmlElement_alias_1 } export { HtmlElement as HtmlElement_alias_2 } /** * Create an inline-styles HTML formatter. Each token gets a `` with * `style="color: ..."` pulled from the theme. * * @example * ```ts * import { htmlInline } from '@lumis-sh/lumis/formatters' * import javascript from '@lumis-sh/lumis/langs/javascript' * import dracula from '@lumis-sh/themes/dracula' * * hl.highlight('const x = 1', htmlInline({ language: javascript, theme: dracula })) * ``` */ declare function htmlInline(options?: HtmlInlineOptions): HtmlInlineFormatter; export { htmlInline } export { htmlInline as htmlInline_alias_1 } declare interface HtmlInlineFormatter extends Formatter, HtmlInlineOptions { } export { HtmlInlineFormatter } export { HtmlInlineFormatter as HtmlInlineFormatter_alias_1 } export { HtmlInlineFormatter as HtmlInlineFormatter_alias_2 } /** * Options for {@link htmlInline}. * * ```ts * htmlInline({ language: javascript, theme: dracula, preClass: 'my-code', italic: true }) * ``` */ declare interface HtmlInlineOptions { language?: LanguageRef; theme?: Theme; preClass?: string; /** Use italic styles from the theme. */ italic?: boolean; /** Add `data-highlight` attributes with scope names. */ includeHighlights?: boolean; /** Render nested brackets with rainbow bracket scopes. */ rainbowBrackets?: boolean; highlightLines?: HighlightLinesInline; header?: HtmlElement; } export { HtmlInlineOptions } export { HtmlInlineOptions as HtmlInlineOptions_alias_1 } export { HtmlInlineOptions as HtmlInlineOptions_alias_2 } /** * Create a class-based HTML formatter. Each token gets a `` with * semantic scope names. Requires a theme CSS file on the page. * * @example * ```ts * import { htmlLinked } from '@lumis-sh/lumis/formatters' * import javascript from '@lumis-sh/lumis/langs/javascript' * import '@lumis-sh/themes/css/dracula.css' * * hl.highlight('const x = 1', htmlLinked({ language: javascript })) * ``` */ declare function htmlLinked(options?: HtmlLinkedOptions): HtmlLinkedFormatter; export { htmlLinked } export { htmlLinked as htmlLinked_alias_1 } declare interface HtmlLinkedFormatter extends Formatter, HtmlLinkedOptions { } export { HtmlLinkedFormatter } export { HtmlLinkedFormatter as HtmlLinkedFormatter_alias_1 } export { HtmlLinkedFormatter as HtmlLinkedFormatter_alias_2 } /** * Options for {@link htmlLinked}. * * ```ts * htmlLinked({ language: javascript, preClass: 'my-code' }) * ``` */ declare interface HtmlLinkedOptions { language?: LanguageRef; preClass?: string; rainbowBrackets?: boolean; highlightLines?: HighlightLinesLinked; header?: HtmlElement; } export { HtmlLinkedOptions } export { HtmlLinkedOptions as HtmlLinkedOptions_alias_1 } export { HtmlLinkedOptions as HtmlLinkedOptions_alias_2 } declare function htmlMultiThemes(options: HtmlMultiThemesOptions): HtmlMultiThemesFormatter; export { htmlMultiThemes } export { htmlMultiThemes as htmlMultiThemes_alias_1 } declare interface HtmlMultiThemesFormatter extends Formatter, HtmlMultiThemesOptions { } export { HtmlMultiThemesFormatter } export { HtmlMultiThemesFormatter as HtmlMultiThemesFormatter_alias_1 } export { HtmlMultiThemesFormatter as HtmlMultiThemesFormatter_alias_2 } /** * Options for {@link htmlMultiThemes}. * * ```ts * htmlMultiThemes({ * language: javascript, * themes: { light: githubLight, dark: githubDark }, * defaultTheme: 'light-dark()', * }) * ``` */ declare interface HtmlMultiThemesOptions { language?: LanguageRef; themes: Record; /** * Theme whose colors are inlined as defaults. * Pass `"light-dark()"` to use the CSS `light-dark()` function instead. */ defaultTheme?: string; /** Prefix for CSS custom properties. Defaults to `"--lumis"`. */ cssVariablePrefix?: string; preClass?: string; italic?: boolean; includeHighlights?: boolean; rainbowBrackets?: boolean; highlightLines?: HighlightLinesInline; header?: HtmlElement; } export { HtmlMultiThemesOptions } export { HtmlMultiThemesOptions as HtmlMultiThemesOptions_alias_1 } export { HtmlMultiThemesOptions as HtmlMultiThemesOptions_alias_2 } export declare const identifierOnlyReference: LanguageRef; export declare const importedHandleWithWasm: LanguagePackageHandle; export declare function initParser(...args: Parameters): Promise; export declare function initParser_alias_1(...args: Parameters): Promise; /** @internal */ export declare function isCompatibleLanguagePackageVersion(version: string): boolean; /** @internal */ export declare function isUrlString(source: string): boolean; /** * Join CSS class names, filtering out falsy values. * * ```ts * joinClasses('l-line', undefined, 'l-highlighted') // "l-line l-highlighted" * joinClasses(undefined, false) // undefined * ``` */ export declare function joinClasses(...classes: Array): string | undefined; /** * A language accepted by Lumis. * * Queries live in the package alongside the parser they were tested against, so * this carries a package name rather than query text. * * ```ts * import javascript from '@lumis-sh/lumis/langs/javascript' * // javascript.id → "javascript" * // javascript.aliases → ["js", "jsx"] * // javascript.packageName → "@lumis-sh/wasm-javascript" * ``` */ declare interface Language extends LanguageDefinition { /** Independently released package containing the parser and matching queries. */ packageName?: string; /** * WASM parser source: * - `WasmRef` fetched from CDN (default for pre-built bundles) * - `Uint8Array` or `ArrayBuffer` passed directly (useful with browser bundlers) * - `URL` fetched directly (`file://` works in Node.js) * - `string` treated as file path (Node.js) or URL (browser) */ wasm?: WasmRef | RuntimeWasmInput; } export { Language } export { Language as Language_alias_1 } export { Language as Language_alias_2 } export declare const LANGUAGE_LOADERS: Record Promise<{ default: Language; }>>; export declare const LANGUAGE_PACKAGE_VERSION_RANGE = "0.26"; /** * A collection of lazy language handles. Import a preset bundle: * * ```ts * import { bundledLanguages } from '@lumis-sh/lumis/bundles/web' * import { bundledLanguages } from '@lumis-sh/lumis/bundles/web-extra' * import { bundledLanguages } from '@lumis-sh/lumis/bundles/system' * import { bundledLanguages } from '@lumis-sh/lumis/bundles/backend' * import { bundledLanguages } from '@lumis-sh/lumis/bundles/full' * ``` */ declare type LanguageBundle = Record; export { LanguageBundle } export { LanguageBundle as LanguageBundle_alias_1 } export { LanguageBundle as LanguageBundle_alias_2 } declare interface LanguageDefinition { id: string; aliases: string[]; } export { LanguageDefinition } export { LanguageDefinition as LanguageDefinition_alias_1 } export { LanguageDefinition as LanguageDefinition_alias_2 } /** * Metadata about a supported language. Returned by {@link availableLanguages}. * * ```ts * import { availableLanguages } from '@lumis-sh/lumis' * const languages = availableLanguages() * // [{ id: 'javascript', name: 'JavaScript', aliases: ['js', 'jsx'], extensions: ['*.js', ...] }, ...] * ``` */ declare interface LanguageInfo { id: string; name: string; aliases: string[]; extensions: string[]; globs: string[]; emacsModes: string[]; shebangs: string[]; } export { LanguageInfo } export { LanguageInfo as LanguageInfo_alias_1 } export { LanguageInfo as LanguageInfo_alias_2 } /** * What `createHighlighter({ languages })` accepts. * * - `Language` — loaded immediately * - `Promise<{ default: Language }>` — e.g. `import('@lumis-sh/lumis/langs/css')` * - `() => Promise<{ default: Language }>` — lazy, loaded when called * - `LanguageBundle` — registered lazily, loaded on first use */ declare type LanguageInput = Language | Promise<{ default: Language; }> | (() => Promise<{ default: Language; }>) | LanguageBundle; export { LanguageInput } export { LanguageInput as LanguageInput_alias_1 } export { LanguageInput as LanguageInput_alias_2 } /** * A language package as published inside `@lumis-sh/wasm-*`. Mirrors * `LanguagePackage` in `crates/lumis-wasm-runtime/src/package.rs`. * * There is deliberately no `formatVersion` gate: runtimes resolve this document * from a compatible range, so the format is additive-only by contract and * compatibility is decided by shape. */ export declare interface LanguagePackage { packageName: string; version: string; definitionHash: string; parser: { name: string; grammarName: string; upstreamVersion?: string; revision?: string; sha256: string; size: number; }; languages: Record; } export declare function languagePackageCacheKey(packageName: string): string; /** * A handle to a published language package. * * Use `wasm` to override where the package's parser bytes come from. The bytes * are still checked against the package's size and SHA-256 before loading. */ declare interface LanguagePackageHandle extends LanguageDefinition { packageName: string; /** Optional caller-selected source for the package's verified parser bytes. */ wasm?: WasmRef | RuntimeWasmInput; } export { LanguagePackageHandle } export { LanguagePackageHandle as LanguagePackageHandle_alias_1 } export { LanguagePackageHandle as LanguagePackageHandle_alias_2 } declare type LanguagePackageResolver = (packageName: string, /** npm range compatible with this runtime's Tree-sitter ABI. */ versionRange: string) => string | URL; export { LanguagePackageResolver } export { LanguagePackageResolver as LanguagePackageResolver_alias_1 } export { LanguagePackageResolver as LanguagePackageResolver_alias_2 } export { LanguagePackageResolver as LanguagePackageResolver_alias_3 } /** * How formatters and `hl.highlight()` identify a language. * * - `LanguageDefinition` — a language object or identifier-only `{ id, aliases }` * - `LazyLanguage` — a handle from a bundle * - `string` — a language ID like `"javascript"` */ declare type LanguageRef = LanguageDefinition | LazyLanguage | string; export { LanguageRef } export { LanguageRef as LanguageRef_alias_1 } export { LanguageRef as LanguageRef_alias_2 } export declare const languageRejectsQueries: Language; export declare const LANGUAGES: LanguageInfo[]; export declare interface LanguagesModule { createRuntime(options?: HighlighterRuntimeOptions): RuntimeLike; configureWasmResolver(fn: WasmResolver): void; configureLanguagePackageResolver(fn: LanguagePackageResolver): void; initParser(): Promise; registerLanguage(def: LanguageDefinition): void; resolveLanguageId(nameOrAlias: string): string; loadLanguage(opts: LoadLanguageOptions): Promise; resolveLanguagePackage(language: LanguageDefinition, packageName: string): Promise; resolveParserWasm(language: string, wasm: WasmRef): Promise; loadPlaintext(): Promise; getLoadedLanguage(nameOrAlias: string): LoadedLanguage | undefined; getLoadedLanguageIds(): string[]; availableLanguages(): LanguageInfo[]; getDefaultRuntime(): RuntimeLike; } export declare function lazy(id: string, aliases: string[], load: () => Promise<{ default: Language; }>): LazyLanguage; /** * A lazy language handle from a bundle. Callable to load the full {@link Language}. * * ```ts * import { bundledLanguages } from '@lumis-sh/lumis/bundles/web' * * bundledLanguages.javascript.id // "javascript" * const language = await bundledLanguages.javascript() // loads the full Language * ``` */ declare interface LazyLanguage { (): Promise; id: string; aliases: string[]; } export { LazyLanguage } export { LazyLanguage as LazyLanguage_alias_1 } export { LazyLanguage as LazyLanguage_alias_2 } /** * Check if a line number is in a list of highlighted lines. * * ```ts * lineIsHighlighted([1, [3, 5]], 4) // true * lineIsHighlighted([1, [3, 5]], 2) // false * ``` */ export declare function lineIsHighlighted(lines: LineSpec[] | undefined, lineNumber: number): boolean; /** * Slice rendered HTML back into lines using offsets from {@link renderEvents}. */ export declare function linesFromOffsets(html: Uint8Array, lineOffsets: number[]): string[]; /** * A single line number (1-based) or `[start, end]` inclusive range. * * ```ts * const lines: LineSpec[] = [1, [3, 5], 8] // lines 1, 3-5, and 8 * ``` */ declare type LineSpec = number | [number, number]; export { LineSpec } export { LineSpec as LineSpec_alias_1 } export { LineSpec as LineSpec_alias_2 } /** * A language definition that contains everything the runtime needs to load it. * * Each variant declares only the fields it owns, so an object literal cannot * pass a forbidden discriminator or load field as explicit `undefined`. * * Queries are not a variant. A parser and the queries written against it are * released together inside a package, so a caller names the package and, at * most, where its parser bytes come from. Supplying queries directly is a * planned feature rather than a supported one; see `ARCHITECTURE.md`. */ declare type LoadableLanguage = LanguagePackageHandle | PlaintextLanguage; export { LoadableLanguage } export { LoadableLanguage as LoadableLanguage_alias_1 } export { LoadableLanguage as LoadableLanguage_alias_2 } /** * The platform addon, ignoring whether this process wants to use it. * * Separate from {@link loadNativeBinding} so a test can assert the addon works * even in a run that has asked for the Wasm runtime. */ export declare function loadAddon(): NativeBinding | undefined; export declare interface LoadedLanguage { definition: LanguageDefinition; parser: Parser; language: Language_2; config: CompiledHighlightConfig; brackets?: CompiledBracketConfig; } /** {@inheritDoc node.loadedLanguages} */ declare function loadedLanguages(): string[]; export { loadedLanguages } export { loadedLanguages as loadedLanguages_alias_2 } /** * Ids of the languages loaded into this process, ready to highlight without a download. * * The complement of {@link availableLanguages}. Elixir spells it `Lumis.loaded_languages/0`. * * ```ts * import { loadedLanguages } from '@lumis-sh/lumis' * loadedLanguages() // ['json', 'rust'] * ``` */ declare function loadedLanguages_2(): string[]; export { loadedLanguages_2 as loadedLanguages_alias_1 } export { loadedLanguages_2 as loadedLanguages_alias_3 } export declare function loadLanguage(...args: Parameters): Promise; export declare function loadLanguage_alias_1(...args: Parameters): Promise; /** * Narrowed to the one method it calls so `loadLanguages()` can share it, rather * than growing a second place that decides what a `Language` becomes on the way * into a runtime. */ export declare function loadLanguageDefinition(runtime: Pick, language: Language): Promise; declare interface LoadLanguageOptions { definition: LanguageDefinition; packageName?: string; /** Where the parser bytes come from. Queries always come from the package. */ wasm?: WasmRef | Uint8Array | ArrayBuffer | string | URL | Response; } export { LoadLanguageOptions } export { LoadLanguageOptions as LoadLanguageOptions_alias_1 } export { LoadLanguageOptions as LoadLanguageOptions_alias_2 } declare type LoadLanguages = (names: Iterable) => Promise; export { LoadLanguages } export { LoadLanguages as LoadLanguages_alias_1 } export { LoadLanguages as LoadLanguages_alias_2 } /** * Load languages into the runtime `highlight()` uses, by name. * * This is the JavaScript spelling of `Lumis.Languages.load/1`: it caches — the * verified parser bytes, and on the native addon their compiled Wasmtime module * — and then keeps the languages in the default runtime, so no later call * reloads them. `cacheLanguages()` does only the caching half, for filling a * directory a different process will read. * * Accepts catalog names, aliases, and `bundle-` tokens. * * Highlighting loads on demand regardless, so this is an optimization. At * startup, prefer not blocking on it: * * ```ts * import { loadLanguages } from '@lumis-sh/lumis' * * await startServer() * * loadLanguages(['javascript', 'html', 'css']).catch((error) => { * logger.warn({ error }, 'Lumis warm-up failed; languages load on demand') * }) * ``` * * Every name is attempted. If any fail, it rejects with an `AggregateError` * naming each one, after the rest have loaded. */ export declare const loadLanguages: LoadLanguages; /** * Load languages into the runtime `highlight()` uses, by name. * * This is the JavaScript spelling of `Lumis.Languages.load/1`: it caches — the * verified parser bytes, and on the native addon their compiled Wasmtime module * — and then keeps the languages in the default runtime, so no later call * reloads them. `cacheLanguages()` does only the caching half, for filling a * directory a different process will read. * * Accepts catalog names, aliases, and `bundle-` tokens. * * Highlighting loads on demand regardless, so this is an optimization. At * startup, prefer not blocking on it: * * ```ts * import { loadLanguages } from '@lumis-sh/lumis' * * await startServer() * * loadLanguages(['javascript', 'html', 'css']).catch((error) => { * logger.warn({ error }, 'Lumis warm-up failed; languages load on demand') * }) * ``` * * Every name is attempted. If any fail, it rejects with an `AggregateError` * naming each one, after the rest have loaded. */ export declare const loadLanguages_alias_1: LoadLanguages; /** Load the platform addon without making native support a public API choice. */ export declare function loadNativeBinding(): NativeBinding | undefined; export declare function loadPlaintext(...args: Parameters): Promise; export declare function loadPlaintext_alias_1(...args: Parameters): Promise; /** How long to sleep between attempts to take a contended lock. */ export declare const LOCK_RETRY_MS = 25; /** When a lock file is old enough that its owner is presumed dead. */ export declare const LOCK_STALE_AFTER_MS = 300000; /** * How long to wait for another process to release a cache lock. * * Deliberately longer than {@link LOCK_STALE_AFTER_MS}: a waiter that gave up * first would fail during the window where it was already entitled to break the * lock. A holder on this machine is detected by pid long before either elapses. */ export declare const LOCK_TIMEOUT_MS: number; declare interface LockOwner { host: string; pid: number; } /** @internal */ export declare function lockOwnerIsGone(owner: LockOwner | undefined, host: string): boolean; /** * The lowest version {@link LANGUAGE_PACKAGE_VERSION_RANGE} accepts. * * Fixtures and staged packages need one concrete version the runtimes will * serve. Deriving it from the range keeps them correct if the range ever stops * being a bare `MAJOR.MINOR` series, which appending `.0` to it would not. * * @internal */ export declare function lowestCompatibleLanguagePackageVersion(): string; export declare function mapBundle(bundle: LanguageBundle, map: (language: Language) => Language): LanguageBundle; export declare function markBuiltinFormatter(formatter: T, kind: BuiltinFormatterKind): T; export declare interface NativeBinding { NativeRuntime: new () => NativeRuntimeInstance; runtimeKind(): string; precompileLanguages(names: string[], directory?: string): Promise; /** `false` once the runtime has read them, which it does on first use. */ configureStore(dataDir?: string): boolean; /** Where the store lives when `LUMIS_DATA_DIR` names nothing. */ defaultDataDir(): string; } export declare type NativeFormatter = NativeFormatterBase & ({ kind: "html-inline"; options: NativeHtmlInlineOptions; } | { kind: "html-linked"; options: NativeHtmlLinkedOptions; } | { kind: "bbcode-scoped"; options: null; } | { kind: "terminal"; options: NativeTerminalOptions; }); declare interface NativeFormatterBase { rainbowBrackets?: boolean; } declare type NativeHtmlInlineOptions = Pick; declare type NativeHtmlLinkedOptions = Pick; export declare interface NativeLanguageSpec { id: string; aliases: string[]; /** Read from the parser's exports when omitted. */ grammarName?: string; highlights: string; injections?: string; locals?: string; brackets?: string; } export declare interface NativeRuntimeInstance { loadLanguage(id: string): void; loadLanguagePackage(id: string, expectedPackageName: string, packageJson: string, wasm: Uint8Array): string; loadInstalledLanguagePackage(id: string, expectedPackageName: string, packageJson: string, wasm: Uint8Array): string; loadLanguageDefinition(spec: NativeLanguageSpec, wasm: Uint8Array): string; hasLanguage(id: string): boolean; cacheLanguage(id: string, directory?: string, force?: boolean): string; highlightEvents(source: string, language: string, rainbowBrackets?: boolean, packageResolver?: (packageName: string) => string | undefined, wasmResolver?: (language: string, wasmJson: string) => string | undefined): { events: Uint8Array; unresolved: string[]; }; format(source: string, language: string, formatter: NativeFormatter, packageResolver?: (packageName: string) => string | undefined, wasmResolver?: (language: string, wasmJson: string) => string | undefined): { output: string; unresolved: string[]; }; formatAsync(source: string, language: string, formatter: NativeFormatter): Promise<{ output: string; unresolved: string[]; }>; } export declare function nativeTarget(): string | undefined; /** * The platform package name for a host, or `undefined` where none is published. * * `native/npm/meta/index.js` repeats this for installs that resolve the addon * through `@lumis-sh/lumis-native`, because that package ships alone and cannot * import from here. `test/native-targets.test.ts` pins the two together and to * the published set, so a new target has to be added in both places. */ export declare function nativeTargetFor(platform: string, arch: string, libc: "gnu" | "musl"): string | undefined; declare type NativeTerminalOptions = Pick; export declare const nodeRuntime: RuntimeEnvironment; declare function normalizeLanguageName(value: string): string; export { normalizeLanguageName } export { normalizeLanguageName as normalizeLanguageName_alias_1 } /** * Open a `` tag with the language class. * * ```ts * openCodeTag(javascript) // '' * ``` */ export declare function openCodeTag(language: LanguageRef | undefined): string; /** * Open a `
` tag with the `lumis` class and optional theme background.
 *
 * ```ts
 * openPreTag({ theme: dracula })
 * // '
'
 * ```
 */
export declare function openPreTag(options?: OpenPreTagOptions): string;

/**
 * Options for {@link openPreTag}.
 *
 * ```ts
 * openPreTag({ preClass: 'my-code', theme: dracula })
 * ```
 */
export declare interface OpenPreTagOptions {
    preClass?: string;
    theme?: Theme;
}

/**
 * Open a `` carrying the given attributes.
 * ```ts
 * openSpanTag({ class: 'l-keyword' })  // ''
 * openSpanTag({})                      // ''
 * ```
 */
export declare function openSpanTag(attrs?: HtmlAttrs): string;

/**
 * Build an opening HTML tag with attributes.
 *
 * ```ts
 * openTag('span', { class: 'keyword', style: 'color: red' })
 * // ''
 * ```
 */
export declare function openTag(name: string, attrs?: HtmlAttrs): string;

export declare interface PackagedLanguage {
    aliases: string[];
    highlights: string;
    injections?: string;
    locals?: string;
    brackets?: string;
}

export declare const packageHandleRejectsQueries: LanguagePackageHandle;

/**
 * Render text with ANSI escape codes from a style, with reset on each newline.
 */
declare function paint(text: string, style: HighlightStyle | undefined): string;
export { paint }
export { paint as paint_alias_1 }

export declare function parseLanguagePackage(data: Uint8Array, expectedPackageName: string): LanguagePackage;

declare type ParserInitOptions = Parameters[0];

export declare const PLAINTEXT_LANG_ID = "plaintext";

declare interface PlaintextLanguage extends LanguageDefinition {
    id: "plaintext";
}
export { PlaintextLanguage }
export { PlaintextLanguage as PlaintextLanguage_alias_1 }
export { PlaintextLanguage as PlaintextLanguage_alias_2 }

export declare const plaintextWithUndefinedWasm: PlaintextLanguage;

/** @internal */
/**
 * `etcetera::choose_base_strategy`, ported: XDG everywhere except Windows, where
 * it is `%APPDATA%`. A relative `XDG_DATA_HOME` is ignored, as the XDG spec
 * requires and as `etcetera` implements.
 *
 * Exported so `test/data-dir-parity.test.ts` can pin it against the addon.
 */
export declare function platformDataDir(): Promise;

/** Deltas from `(#offset! @capture start_row start_col end_row end_col)`. */
export declare interface QueryCaptureOffset {
    startRow: number;
    startColumn: number;
    endRow: number;
    endColumn: number;
}

/** @internal */
export declare function readCachedWasm(key: string, directory?: string): Promise;

export declare function registerLanguage(...args: Parameters): void;

export declare function registerLanguage_alias_1(...args: Parameters): void;

/**
 * Render highlight events into a single HTML buffer plus line offsets.
 *
 * The returned offsets can be passed to {@link linesFromOffsets}.
 */
export declare function renderEvents(source: string, events: HighlightEvent_2[], attributeCallback: (scope: string, language: string, html: string[]) => void): [Uint8Array, number[]];

export declare function renderHtmlBlock(options: {
    lines: string[];
    language: LanguageRef | undefined;
    pre: string;
    lineOptions: (lineNumber: number) => {
        className?: string;
        style?: string;
    };
    header?: HtmlElement;
}): string;

/**
 * Render highlight events into escaped HTML lines, reopening active spans across newlines.
 *
 * ```ts
 * renderLinesFromEvents('a\nb', events, (scope) => `class="${scope}"`)
 * // ['a', 'b']
 * ```
 */
export declare function renderLinesFromEvents(source: string, events: HighlightEvent_2[], spanAttrs: (scope: string, language: string) => string): string[];

export declare interface ResolvedLanguagePackage {
    definition: LanguageDefinition;
    wasm: WasmRef;
    grammarName: string;
    highlights: string;
    injections?: string;
    locals?: string;
    brackets?: string;
}

/** Resolve one catalog name or alias to its language definition. */
export declare function resolveLanguage(name: string): Promise;

export declare function resolveLanguageId(...args: Parameters): string;

export declare function resolveLanguageId_alias_1(...args: Parameters): string;

export declare const resolverOptions: CreateHighlighterOptions;

/**
 * Build an ANSI 24-bit color escape sequence.
 *
 * ```ts
 * rgbToAnsi(255, 121, 198, false)  // "\x1b[38;2;255;121;198m" (foreground)
 * rgbToAnsi(40, 42, 54, true)      // "\x1b[48;2;40;42;54m" (background)
 * ```
 */
declare function rgbToAnsi(r: number, g: number, b: number, isBackground: boolean): string;
export { rgbToAnsi }
export { rgbToAnsi as rgbToAnsi_alias_1 }

declare const runtime: LanguagesModule;

export declare interface RuntimeEnvironment {
    resolveWasm(wasm: Uint8Array | ArrayBuffer | string | URL | Response): Promise;
    readFsCache(key: string): Promise;
    writeFsCache(key: string, data: Uint8Array): Promise;
    withFsCacheLock(key: string, operation: () => Promise): Promise;
    /** Read a file already under `$LUMIS_DATA_DIR/parsers`, where the runtime has one. */
    readStagedAsset?(filename: string): Promise;
    readResolvedWasmFromDisk(source: string | URL): Promise;
    parserInitOptions?(): Promise;
}

export declare interface RuntimeEnvironmentResolver {
    language: string;
    ref: WasmRef;
}

/**
 * {@inheritDoc node.runtimeKind}
 *
 * Always `"wasm"` in a browser: the native addon is a Node addon.
 */
declare function runtimeKind(): "native" | "wasm";
export { runtimeKind }
export { runtimeKind as runtimeKind_alias_2 }

/**
 * Which runtime is highlighting: the native addon, or `web-tree-sitter`.
 *
 * Node prefers the addon and falls back silently, so anything that needs to
 * know which one it got — a benchmark reporting a number, a bug report — has to
 * be able to ask.
 *
 * ```ts
 * import { runtimeKind } from '@lumis-sh/lumis'
 * runtimeKind() // 'native' | 'wasm'
 * ```
 */
declare function runtimeKind_2(): "native" | "wasm";
export { runtimeKind_2 as runtimeKind_alias_1 }
export { runtimeKind_2 as runtimeKind_alias_3 }

declare interface RuntimeLike {
    configureWasmResolver(fn: WasmResolver): void;
    configureLanguagePackageResolver(fn: LanguagePackageResolver): void;
    initParser(): Promise;
    registerLanguage(def: LanguageDefinition): void;
    resolveLanguageId(nameOrAlias: string): string;
    getLoadedLanguage(nameOrAlias: string): LoadedLanguage | undefined;
    getLoadedLanguageIds(): string[];
    loadLanguage(opts: LoadLanguageOptions): Promise;
    resolveLanguagePackage(language: LanguageDefinition, packageName: string): Promise;
    /** Parser bytes for `wasm`, resolved through this runtime's resolver, verified and cached. */
    resolveParserWasm(language: string, wasm: WasmRef): Promise;
    loadPlaintext(): Promise;
    highlightEvents(source: string, language: LoadedLanguage, options?: {
        rainbowBrackets?: boolean;
    }): HighlightEvent_2[];
    format?(source: string, language: LoadedLanguage, formatter: Formatter): string | undefined;
    formatAsync?(source: string, language: LoadedLanguage, formatter: Formatter): Promise;
}
export { RuntimeLike }
export { RuntimeLike as RuntimeLike_alias_1 }
export { RuntimeLike as RuntimeLike_alias_2 }

declare interface RuntimeLookup {
    getLoadedLanguage(nameOrAlias: string): LoadedLanguage | undefined;
}

declare type RuntimeWasmBundle = Partial>;
export { RuntimeWasmBundle }
export { RuntimeWasmBundle as RuntimeWasmBundle_alias_1 }
export { RuntimeWasmBundle as RuntimeWasmBundle_alias_2 }

declare type RuntimeWasmInput = Uint8Array | ArrayBuffer | string | URL | Response;
export { RuntimeWasmInput }
export { RuntimeWasmInput as RuntimeWasmInput_alias_1 }
export { RuntimeWasmInput as RuntimeWasmInput_alias_2 }

/**
 * Replace non-alphanumeric characters in a theme name with hyphens.
 *
 * ```ts
 * sanitizeThemeName('github light')  // "github-light"
 * ```
 */
declare function sanitizeThemeName(name: string): string;
export { sanitizeThemeName }
export { sanitizeThemeName as sanitizeThemeName_alias_1 }
export { sanitizeThemeName as sanitizeThemeName_alias_2 }
export { sanitizeThemeName as sanitizeThemeName_alias_3 }

/**
 * Convert a dot-separated scope to a CSS class name.
 *
 * ```ts
 * scopeToClass('string.special.regex')  // "l-string-special-regex"
 * ```
 */
export declare function scopeToClass(scope: string): string;

export declare function serializeLanguagePackageCache(packageMetadata: LanguagePackage): Uint8Array;

declare interface SharedRuntimeCache {
    parserInit?: Promise;
    wasmBytes: Map;
    wasmLoads: Map>;
    packages: Map;
    packageLoads: Map>;
}
export { SharedRuntimeCache }
export { SharedRuntimeCache as SharedRuntimeCache_alias_1 }
export { SharedRuntimeCache as SharedRuntimeCache_alias_2 }

export declare const SHEBANG_MAP: Record;

/**
 * Theme names in a stable order.
 *
 * Rust holds themes in a `HashMap` and sorts before emitting, so this has to
 * sort rather than follow insertion order for the two to agree byte for byte.
 *
 * `Array.prototype.sort` orders by UTF-16 code unit, which puts astral
 * characters before U+E000..U+FFFF; Rust orders `&str` by UTF-8 byte, which
 * puts them after. Comparing the encoded bytes is what makes the two agree.
 *
 * Exported for the multi-themes formatter next door, not for callers; Rust
 * keeps its counterpart private.
 * @internal
 */
export declare function sortedThemeNames(themes: Record): string[];

export declare interface SourceMaps {
    utf8Offsets: number[];
    utf16Indices: Array;
    lineStarts: number[];
    byteLineStarts: number[];
    sourceBytes: Uint8Array;
    sourceLength: number;
    sourceUtf8ByteLength: number;
}

/**
 * Render an inline-styled `` for a token.
 * ```ts
 * spanInline('const', { language: 'javascript', scope: 'keyword', theme: dracula })
 * // 'const'
 *
 * spanInline('const', { language: 'javascript', scope: 'keyword', theme: undefined })
 * // 'const'
 * ```
 */
export declare function spanInline(text: string, options: SpanInlineOptions): string;

/**
 * Build HTML attributes for an inline-styled ``.
 *
 * ```ts
 * spanInlineAttrs({ language: 'javascript', scope: 'keyword', theme: dracula })
 * // { style: "color: #ff79c6;" }
 * ```
 */
export declare function spanInlineAttrs(options: SpanInlineOptions): HtmlAttrs;

/**
 * Options for {@link spanInline} and {@link spanInlineAttrs}.
 *
 * ```ts
 * spanInline('const', { language: 'javascript', scope: 'keyword', theme: dracula })
 * ```
 */
export declare interface SpanInlineOptions {
    language: LanguageRef;
    scope: string;
    theme?: Theme;
    italic?: boolean;
    includeHighlights?: boolean;
}

/**
 * Render a class-based `` for a token.
 *
 * ```ts
 * spanLinked('const', 'keyword')  // 'const'
 * ```
 */
export declare function spanLinked(text: string, scope: string): string;

/**
 * Build HTML attributes for a class-based ``.
 *
 * ```ts
 * spanLinkedAttrs('keyword')  // 'class="l-keyword"'
 * ```
 */
export declare function spanLinkedAttrs(scope: string): string;

/**
 * Render a multi-theme `` with CSS custom properties.
 *
 * ```ts
 * spanMultiThemes('const', {
 *   language: 'javascript',
 *   scope: 'keyword',
 *   themes: { light: githubLight, dark: githubDark },
 *   defaultTheme: 'light-dark()',
 * })
 * ```
 */
export declare function spanMultiThemes(text: string, options: SpanMultiThemesOptions): string;

/**
 * Build HTML attributes for a multi-theme `` with CSS custom properties.
 *
 * ```ts
 * spanMultiThemesAttrs({ language: 'js', scope: 'keyword', themes: { light: l, dark: d } })
 * // { style: "--lumis-light:#000; --lumis-dark:#fff; ..." }
 * ```
 */
export declare function spanMultiThemesAttrs(options: SpanMultiThemesOptions): HtmlAttrs;

/**
 * Options for {@link spanMultiThemes} and {@link spanMultiThemesAttrs}.
 *
 * ```ts
 * spanMultiThemes('const', {
 *   language: 'javascript',
 *   scope: 'keyword',
 *   themes: { light: githubLight, dark: githubDark },
 *   defaultTheme: 'light-dark()',
 * })
 * ```
 */
export declare interface SpanMultiThemesOptions {
    language: LanguageRef;
    scope: string;
    themes: Record;
    defaultTheme?: string;
    /** Defaults to `"--lumis"`. */
    cssVariablePrefix?: string;
    italic?: boolean;
    includeHighlights?: boolean;
}

/**
 * Convert a `HighlightStyle` to ANSI escape codes.
 *
 * ```ts
 * styleToAnsi({ fg: '#ff79c6', bold: true })
 * // "\x1b[38;2;255;121;198m\x1b[1m"
 * ```
 */
declare function styleToAnsi(style: HighlightStyle | undefined): string;
export { styleToAnsi }
export { styleToAnsi as styleToAnsi_alias_1 }

/**
 * Convert a `HighlightStyle` to inline CSS declarations.
 *
 * ```ts
 * styleToCss({ fg: '#ff79c6', bold: true })
 * // "color: #ff79c6; font-weight: bold;"
 * ```
 */
export declare function styleToCss(style: HighlightStyle | undefined, options?: {
    italic?: boolean;
    separator?: string;
    compact?: boolean;
}): string;

declare function terminal(options?: TerminalOptions): TerminalFormatter;
export { terminal }
export { terminal as terminal_alias_1 }

declare interface TerminalFormatter extends Formatter, TerminalOptions {
}
export { TerminalFormatter }
export { TerminalFormatter as TerminalFormatter_alias_1 }
export { TerminalFormatter as TerminalFormatter_alias_2 }
export { TerminalFormatter as TerminalFormatter_alias_3 }

/**
 * Options for {@link terminal}.
 *
 * ```ts
 * terminal({ language: javascript, theme: dracula })
 * terminal({ language: javascript, theme: dracula, background: 'theme', width: 120 })
 * ```
 */
declare interface TerminalOptions {
    language?: LanguageRef;
    theme?: Theme;
    /**
     * Fallback background for text the theme gives no background.
     *
     * Omit it to inherit the terminal's own background. `"theme"` reuses the
     * theme's `normal` background. Any other string is used as the color.
     */
    background?: string;
    /**
     * Pad each rendered line out to this width. Only takes effect alongside
     * {@link TerminalOptions.background}, since padding is only visible as
     * background fill.
     */
    width?: number;
    rainbowBrackets?: boolean;
}
export { TerminalOptions }
export { TerminalOptions as TerminalOptions_alias_1 }
export { TerminalOptions as TerminalOptions_alias_2 }
export { TerminalOptions as TerminalOptions_alias_3 }

/**
 * Build a CSS `text-decoration` value from a style.
 *
 * ```ts
 * textDecoration({ underline: 'wavy', strikethrough: true })
 * // "underline wavy line-through"
 * ```
 */
export declare function textDecoration(style: HighlightStyle): string;

/**
 * Theme with color and style mappings for syntax scopes.
 *
 * ```ts
 * import dracula from '@lumis-sh/themes/dracula'
 * // dracula.name        → "dracula"
 * // dracula.appearance  → "dark"
 * // dracula.highlights  → { "keyword": { fg: "#ff79c6" }, ... }
 * ```
 */
declare interface Theme {
    name: string;
    appearance: "light" | "dark";
    revision?: string;
    highlights: Record;
}
export { Theme }
export { Theme as Theme_alias_1 }
export { Theme as Theme_alias_2 }

/**
 * Metadata about a built-in theme. Returned by {@link availableThemes}.
 *
 * ```ts
 * import { availableThemes } from '@lumis-sh/lumis'
 * const themes = availableThemes()
 * // [{ name: 'dracula', appearance: 'dark' }, { name: 'github_light', appearance: 'light' }, ...]
 * ```
 */
declare interface ThemeInfo {
    name: string;
    appearance: "light" | "dark";
}
export { ThemeInfo }
export { ThemeInfo as ThemeInfo_alias_1 }
export { ThemeInfo as ThemeInfo_alias_2 }

export declare const THEMES: ThemeInfo[];

/** @internal */
export declare function verifyWasm(ref: WasmRef, data: Uint8Array): Promise;

/**
 * Say so when a document named a language that is not loaded.
 *
 * `web-tree-sitter` cannot fetch a parser inside a synchronous walk, so the
 * block stays plain. The native addon reports the same thing from Rust, so both
 * Node runtimes behave and sound identical.
 *
 * An injection query can name something that is not a language at all: html
 * captures the raw `