/** * The peer-neutral highlighter capability used by Lyra's code-rendering components. * * This deliberately describes only the operations Lyra invokes. It keeps public declarations * useful without requiring consumers to install Shiki merely to type-check an element reference. */ export interface ShikiHighlighter{codeToHtml(code:string,options:Record):string;getLoadedLanguages():string[];loadLanguage(language:string|ShikiLanguageInput):Promise;} /** * A fine-grained Shiki highlighter has the same capability surface Lyra consumes as the default * highlighter, but is constructed from application-supplied grammars. */ export type ShikiHighlighterCore=ShikiHighlighter; /** * Narrows an unknown value (the resolved output of `shiki`'s `createHighlighter()`/ * `createHighlighterCore()`) to the highlighter capability Lyra actually calls. Both * `loadShikiHighlighter()` (`code-loader.ts`) and `loadShikiHighlighterCore()` below validate * their built instance through this before caching/returning it, so a malformed or spoofed peer * fails closed at load time -- resolving `null` with the documented warning -- instead of reaching * ``/``'s render path and throwing there. Exported so a call site that * receives an already-resolved highlighter from elsewhere (e.g. `syncHighlight()`'s live * per-language check) can also tolerate a shape-valid peer whose method throws only when actually * invoked, which a load-time shape check alone cannot catch. */ export declare function isShikiHighlighter(candidate:unknown):candidate is ShikiHighlighter; /** The peer-neutral shape of one TextMate grammar registration. */ export interface ShikiLanguageRegistration{name:string;scopeName:string;displayName?:string;aliases?:string[];patterns?:unknown[];repository?:Record;} /** A pre-imported Shiki language module's default export. Shiki 4 language modules export an * array because one language entry can register multiple related TextMate grammars. */ export type ShikiLanguageInput=ShikiLanguageRegistration|readonly ShikiLanguageRegistration[]; /** A `languages` entry that hasn't been imported/resolved yet -- called at most once per * distinct (`HighlighterCore`, normalized key) pair, the first time that key is actually * requested (see `ensureShikiLanguageLoaded()`). May return either a grammar directly or an ES * module namespace/default-export wrapper around one, matching a plain * `() => import('@shikijs/langs/')` call site verbatim -- no `.then(m => m.default)` * required from the caller. */ export type ShikiLanguageLoader=()=>Promise; /** One `languages` map entry: either an already-resolved grammar (today's contract, seeded eagerly * into the `HighlighterCore` at creation) or a {@link ShikiLanguageLoader}, resolved and loaded * into the core lazily via `HighlighterCore.loadLanguage()` the first time a fence actually * requests that key -- see `resolvedShikiLanguages()` and `ensureShikiLanguageLoaded()`. */ export type ShikiLanguageSource=ShikiLanguageInput|ShikiLanguageLoader; /** The subset of a Shiki/HAST element node that Lyra's transformers mutate. */ interface ShikiTransformerNode{properties:Record &{part?:unknown;role?:unknown;};} /** * The peer-neutral transformer hooks used by Lyra's code and Markdown renderers. * Consumers do not need Shiki installed merely to consume the generated declarations. */ export interface ShikiTransformer{name?:string;pre?(node:ShikiTransformerNode):void;code?(node:ShikiTransformerNode):void;line?(node:ShikiTransformerNode,line:number):void;}export declare const SHIKI_LIGHT_THEME:string;export declare const SHIKI_DARK_THEME:string; /** Passed directly as `codeToHtml()`'s dual-theme option. */ export declare const SHIKI_THEMES:Record<'light'|'dark',string>; /** Normalizes ids supplied by filename-oriented integrations and templates. */ export declare function normalizeShikiLanguage(lang:string):string; /** * The peer-neutral regex-scanning capability `createHighlighterCore()`'s own `engine` option * accepts. Lyra never calls either method itself -- a resolved value is only ever forwarded * straight through to Shiki's own `createHighlighterCore()` -- so this need only describe the * shape well enough to type-check a consumer-supplied factory, the same "just enough to * type-check" contract as {@link ShikiHighlighter} above. */ export interface ShikiRegexEngine{createScanner(patterns:readonly(string|RegExp)[]):unknown;createString(value:string):unknown;} /** A factory `setShikiCoreEngine()` accepts directly: called once per distinct `languages` object * on first use, producing (synchronously or via a promise) the engine `loadShikiHighlighterCore()` * builds its `HighlighterCore` with. */ export type ShikiRegexEngineFactory=()=>ShikiRegexEngine|Promise; /** `setShikiCoreEngine()`'s accepted values -- either of the two built-in presets, or a caller- * supplied factory for a pre-instantiated engine or a WASM asset served from elsewhere. */ export type ShikiEngineOption='oniguruma'|'javascript'|ShikiRegexEngineFactory; /** * Selects the regex-scanning engine every subsequent `loadShikiHighlighterCore()` call builds its * `HighlighterCore` with. `'oniguruma'` (the default) is the binary-WASM Oniguruma engine * documented on {@link defaultOnigurumaEngineFactory}; `'javascript'` selects * `createJavaScriptRegexEngine()` instead. A function value is called on first use per distinct * `languages` object and may return a {@link ShikiRegexEngine} synchronously or via a promise, for * a consumer supplying its own pre-instantiated engine or a WASM asset served from a different URL. * Every distinct engine gets its own cached `HighlighterCore` per `languages` object -- two engines * never share one, so switching engines mid-session cannot return a highlighter built for the * previous one. */ export declare function setShikiCoreEngine(engine:ShikiEngineOption):void; /** * Builds and caches a fine-grained `HighlighterCore` seeded with only the supplied grammars. * The identity cache also shares recently used equivalent, deeply frozen plain grammar maps. * This bounded weak reuse never changes mutable or unusual inputs' identity-only caching. * Only Shiki subpaths are imported here; the package's main entry and full grammar table remain * unreachable from lean component graphs. */ export declare function loadShikiHighlighterCore(languages:Record):Promise; /** * The already-resolved subset of a `languages` map that may also contain lazy * {@link ShikiLanguageLoader} entries -- the subset `loadShikiHighlighterCore()` seeds a * `HighlighterCore` with at creation; a loader entry contributes nothing at seed time and is * loaded lazily instead, via `ensureShikiLanguageLoaded()`, the first time a fence actually * requests it. * * When `languages` contains no loader at all, the very same object is returned unchanged -- * preserving `loadShikiHighlighterCore()`'s own identity-keyed cache for every caller that never * uses a loader, unchanged from before this function existed. Otherwise the derived subset is * memoized per input object identity, so a caller that re-derives it on every render for the same * stable `languages` object still gets the same output object back, and therefore still hits * `loadShikiHighlighterCore()`'s identity cache instead of rebuilding (and re-seeding) a * `HighlighterCore` on every call. */ export declare function resolvedShikiLanguages(languages:Readonly>):Record; /** * Resolves one `languages` entry that may be a {@link ShikiLanguageLoader}, loading it into `core` * via `HighlighterCore.loadLanguage()` the first time a given (core, key) pair is seen. Resolves to * `true` immediately, with no work done, for an entry that is already a plain grammar -- * `loadShikiHighlighterCore()` already seeded that one into `core` at creation. Never rejects: a * loader that throws, or a `loadLanguage()` call that rejects, resolves to `false` instead (with a * one-time dev warning), so a caller can render the plain-text fallback for that key the same way * it already does for a key absent from `languages` altogether. * * Unlike an already-resolved entry (seeded through `buildShikiLangAlias()` at core creation, so an * author-chosen `languages` key never needs to match the grammar's own registered name), a lazily * loaded grammar is registered under whatever name/aliases it declares *itself* -- `loadLanguage()` * has no alias parameter. `codeToHtml`/`tokenize` calls must therefore request the grammar's own * name or a declared alias, not an arbitrary `languages` key, unless that key already happens to be * one of those (true for shiki's own bundled grammars keyed by their conventional short id, e.g. * `bash`/`ts`). */ export declare function ensureShikiLanguageLoaded(core:ShikiHighlighterCore,key:string,source:ShikiLanguageSource):Promise;export{};