@shikijs/core 1.16.3 → 1.17.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 CHANGED
@@ -1,12 +1,12 @@
1
- import { Root, RootContent, Nodes, Element } from 'hast';
2
- import { R as RequireKeys, L as LoadWasmOptions, J as JavaScriptRegexEngineOptions, a as RegexEngine, M as MaybeArray, b as MaybeGetter } from './chunk-engines.mjs';
3
- export { A as Awaitable, e as LoadWasmOptionsPlain, f as MaybeModule, O as OnigurumaLoadOptions, P as PatternScanner, c as RegexEngineString, S as StringLiteralUnion, d as WebAssemblyInstance, W as WebAssemblyInstantiator } from './chunk-engines.mjs';
4
- import { BundledHighlighterOptions, HighlighterGeneric, CreatedBundledHighlighterOptions, LanguageInput, ThemeInput, HighlighterCoreOptions, CodeToHastOptions, CodeToTokensOptions, TokensResult, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, GrammarState, HighlighterCore, ShikiInternal, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, ThemeRegistrationResolved, TokenizeWithThemeOptions, ThemeRegistrationAny, ShikiTransformer, PlainTextLanguage, SpecialLanguage, SpecialTheme, TokenStyles, Position } from './types.mjs';
5
- export { AnsiLanguage, BundledLanguageInfo, BundledThemeInfo, CodeOptionsMeta, CodeOptionsMultipleThemes, CodeOptionsSingleTheme, CodeOptionsThemes, CodeToHastOptionsCommon, CodeToHastRenderOptionsCommon, DecorationItem, DecorationOptions, DecorationTransformType, DynamicImportLanguageRegistration, DynamicImportThemeRegistration, FontStyle, Grammar, LanguageRegistration, Offset, OffsetOrPosition, ResolveBundleKey, ResolvedDecorationItem, ResolvedPosition, ShikiTransformerContext, ShikiTransformerContextMeta, ThemeRegistration, ThemeRegistrationRaw, ThemedTokenExplanation, ThemedTokenScopeExplanation, TokenBase, TransformerOptions } from './types.mjs';
1
+ import { CreatedBundledHighlighterOptions, CreateHighlighterFactory, LanguageInput, ThemeInput, HighlighterCoreOptions, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, HighlighterGeneric, GrammarState, HighlighterCore, ShikiInternal, LoadWasmOptions, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, ThemeRegistrationResolved, TokenizeWithThemeOptions, ThemeRegistrationAny, ShikiTransformer, MaybeArray, PlainTextLanguage, SpecialLanguage, SpecialTheme, MaybeGetter, TokenStyles, Position } from '@shikijs/types';
2
+ export * from '@shikijs/types';
3
+ import { Root, Element } from 'hast';
4
+ export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
6
5
  import { IGrammar } from '@shikijs/vscode-textmate';
7
- export { IRawGrammar as RawGrammar, IRawTheme as RawTheme, IRawThemeSetting as RawThemeSetting, EncodedTokenMetadata as StackElementMetadata } from '@shikijs/vscode-textmate';
6
+ export { FontStyle, EncodedTokenMetadata as StackElementMetadata } from '@shikijs/vscode-textmate';
7
+ export { createWasmOnigEngine, loadWasm } from '@shikijs/engine-oniguruma';
8
+ export { toHtml as hastToHtml } from 'hast-util-to-html';
8
9
 
9
- type CreateHighlighterFactory<L extends string, T extends string> = (options: BundledHighlighterOptions<L, T>) => Promise<HighlighterGeneric<L, T>>;
10
10
  /**
11
11
  * Create a `createHighlighter` function with bundled themes, languages, and engine.
12
12
  *
@@ -106,11 +106,6 @@ declare const getSingletonHighlighterCore: (options?: Partial<HighlighterCoreOpt
106
106
  */
107
107
  declare function getHighlighterCore(options?: HighlighterCoreOptions): Promise<HighlighterCore>;
108
108
 
109
- /**
110
- * Set the default wasm loader for `loadWasm`.
111
- * @internal
112
- */
113
- declare function setDefaultWasmLoader(_loader: LoadWasmOptions): void;
114
109
  /**
115
110
  * Get the minimal shiki context for rendering.
116
111
  */
@@ -128,250 +123,14 @@ declare function getShikiInternal(options?: HighlighterCoreOptions): Promise<Shi
128
123
  declare function createShikiInternalSync(options: HighlighterCoreOptions<true>): ShikiInternal;
129
124
 
130
125
  /**
131
- * The default RegExp constructor for JavaScript regex engine.
132
- */
133
- declare function defaultJavaScriptRegexConstructor(pattern: string): RegExp;
134
- /**
135
- * Use the modern JavaScript RegExp engine to implement the OnigScanner.
136
- *
137
- * As Oniguruma regex is more powerful than JavaScript regex, some patterns may not be supported.
138
- * Errors will be thrown when parsing TextMate grammars with unsupported patterns.
139
- * Set `forgiving` to `true` to ignore these errors and skip the unsupported patterns.
140
- *
141
- * @experimental
126
+ * Set the default wasm loader for `loadWasm`.
127
+ * @internal
142
128
  */
143
- declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
144
-
145
- declare function loadWasm(options: LoadWasmOptions): Promise<void>;
146
-
147
- declare function createWasmOnigEngine(options?: LoadWasmOptions | null): Promise<RegexEngine>;
148
-
149
- declare class ShikiError extends Error {
150
- constructor(message: string);
151
- }
129
+ declare function setDefaultWasmLoader(_loader: LoadWasmOptions): void;
152
130
 
153
131
  declare function codeToHast(internal: ShikiInternal, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
154
132
  declare function tokensToHast(tokens: ThemedToken[][], options: CodeToHastRenderOptions, transformerContext: ShikiTransformerContextSource): Root;
155
133
 
156
- type FormatSmartOptions = {
157
- /**
158
- * Prefer named character references (`&amp;`) where possible.
159
- */
160
- useNamedReferences?: boolean | undefined
161
- /**
162
- * Prefer the shortest possible reference, if that results in less bytes.
163
- * **Note**: `useNamedReferences` can be omitted when using `useShortestReferences`.
164
- */
165
- useShortestReferences?: boolean | undefined
166
- /**
167
- * Whether to omit semicolons when possible.
168
- * **Note**: This creates what HTML calls “parse errors” but is otherwise still valid HTML — don’t use this except when building a minifier.
169
- * Omitting semicolons is possible for certain named and numeric references in some cases.
170
- */
171
- omitOptionalSemicolons?: boolean | undefined
172
- /**
173
- * Create character references which don’t fail in attributes.
174
- * **Note**: `attribute` only applies when operating dangerously with
175
- * `omitOptionalSemicolons: true`.
176
- */
177
- attribute?: boolean | undefined
178
- }
179
-
180
- type CoreOptions = {
181
- /**
182
- * Whether to only escape the given subset of characters.
183
- */
184
- subset?: string[] | undefined
185
- /**
186
- * Whether to only escape possibly dangerous characters.
187
- * Those characters are `"`, `&`, `'`, `<`, `>`, and `` ` ``.
188
- */
189
- escapeOnly?: boolean | undefined
190
- }
191
-
192
- type Options$2 = CoreOptions &
193
- FormatSmartOptions
194
-
195
- type Options$1 = Options$2
196
-
197
- /**
198
- * Serialize hast as HTML.
199
- *
200
- * @param {Array<RootContent> | Nodes} tree
201
- * Tree to serialize.
202
- * @param {Options | null | undefined} [options]
203
- * Configuration (optional).
204
- * @returns {string}
205
- * Serialized HTML.
206
- */
207
- declare function toHtml(tree: Array<RootContent> | Nodes, options?: Options | null | undefined): string;
208
- type CharacterReferences = Omit<Options$1, "attribute" | "escapeOnly" | "subset">;
209
- /**
210
- * Configuration.
211
- */
212
- type Options = {
213
- /**
214
- * Do not encode some characters which cause XSS vulnerabilities in older
215
- * browsers (default: `false`).
216
- *
217
- * > ⚠️ **Danger**: only set this if you completely trust the content.
218
- */
219
- allowDangerousCharacters?: boolean | null | undefined;
220
- /**
221
- * Allow `raw` nodes and insert them as raw HTML (default: `false`).
222
- *
223
- * When `false`, `Raw` nodes are encoded.
224
- *
225
- * > ⚠️ **Danger**: only set this if you completely trust the content.
226
- */
227
- allowDangerousHtml?: boolean | null | undefined;
228
- /**
229
- * Do not encode characters which cause parse errors (even though they work),
230
- * to save bytes (default: `false`).
231
- *
232
- * Not used in the SVG space.
233
- *
234
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
235
- * > errors are handled is well defined, so this works but isn’t pretty).
236
- */
237
- allowParseErrors?: boolean | null | undefined;
238
- /**
239
- * Use “bogus comments” instead of comments to save byes: `<?charlie>`
240
- * instead of `<!--charlie-->` (default: `false`).
241
- *
242
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
243
- * > errors are handled is well defined, so this works but isn’t pretty).
244
- */
245
- bogusComments?: boolean | null | undefined;
246
- /**
247
- * Configure how to serialize character references (optional).
248
- */
249
- characterReferences?: CharacterReferences | null | undefined;
250
- /**
251
- * Close SVG elements without any content with slash (`/`) on the opening tag
252
- * instead of an end tag: `<circle />` instead of `<circle></circle>`
253
- * (default: `false`).
254
- *
255
- * See `tightSelfClosing` to control whether a space is used before the
256
- * slash.
257
- *
258
- * Not used in the HTML space.
259
- */
260
- closeEmptyElements?: boolean | null | undefined;
261
- /**
262
- * Close self-closing nodes with an extra slash (`/`): `<img />` instead of
263
- * `<img>` (default: `false`).
264
- *
265
- * See `tightSelfClosing` to control whether a space is used before the
266
- * slash.
267
- *
268
- * Not used in the SVG space.
269
- */
270
- closeSelfClosing?: boolean | null | undefined;
271
- /**
272
- * Collapse empty attributes: get `class` instead of `class=""` (default:
273
- * `false`).
274
- *
275
- * Not used in the SVG space.
276
- *
277
- * > 👉 **Note**: boolean attributes (such as `hidden`) are always collapsed.
278
- */
279
- collapseEmptyAttributes?: boolean | null | undefined;
280
- /**
281
- * Omit optional opening and closing tags (default: `false`).
282
- *
283
- * For example, in `<ol><li>one</li><li>two</li></ol>`, both `</li>` closing
284
- * tags can be omitted.
285
- * The first because it’s followed by another `li`, the last because it’s
286
- * followed by nothing.
287
- *
288
- * Not used in the SVG space.
289
- */
290
- omitOptionalTags?: boolean | null | undefined;
291
- /**
292
- * Leave attributes unquoted if that results in less bytes (default: `false`).
293
- *
294
- * Not used in the SVG space.
295
- */
296
- preferUnquoted?: boolean | null | undefined;
297
- /**
298
- * Use the other quote if that results in less bytes (default: `false`).
299
- */
300
- quoteSmart?: boolean | null | undefined;
301
- /**
302
- * Preferred quote to use (default: `'"'`).
303
- */
304
- quote?: Quote | null | undefined;
305
- /**
306
- * When an `<svg>` element is found in the HTML space, this package already
307
- * automatically switches to and from the SVG space when entering and exiting
308
- * it (default: `'html'`).
309
- *
310
- * > 👉 **Note**: hast is not XML.
311
- * > It supports SVG as embedded in HTML.
312
- * > It does not support the features available in XML.
313
- * > Passing SVG might break but fragments of modern SVG should be fine.
314
- * > Use [`xast`][xast] if you need to support SVG as XML.
315
- */
316
- space?: Space | null | undefined;
317
- /**
318
- * Join attributes together, without whitespace, if possible: get
319
- * `class="a b"title="c d"` instead of `class="a b" title="c d"` to save
320
- * bytes (default: `false`).
321
- *
322
- * Not used in the SVG space.
323
- *
324
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
325
- * > errors are handled is well defined, so this works but isn’t pretty).
326
- */
327
- tightAttributes?: boolean | null | undefined;
328
- /**
329
- * Join known comma-separated attribute values with just a comma (`,`),
330
- * instead of padding them on the right as well (`,␠`, where `␠` represents a
331
- * space) (default: `false`).
332
- */
333
- tightCommaSeparatedLists?: boolean | null | undefined;
334
- /**
335
- * Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of
336
- * `<!doctype html>` to save bytes (default: `false`).
337
- *
338
- * > 👉 **Note**: intentionally creates parse errors in markup (how parse
339
- * > errors are handled is well defined, so this works but isn’t pretty).
340
- */
341
- tightDoctype?: boolean | null | undefined;
342
- /**
343
- * Do not use an extra space when closing self-closing elements: `<img/>`
344
- * instead of `<img />` (default: `false`).
345
- *
346
- * > 👉 **Note**: only used if `closeSelfClosing: true` or
347
- * > `closeEmptyElements: true`.
348
- */
349
- tightSelfClosing?: boolean | null | undefined;
350
- /**
351
- * Use a `<!DOCTYPE…` instead of `<!doctype…` (default: `false`).
352
- *
353
- * Useless except for XHTML.
354
- */
355
- upperDoctype?: boolean | null | undefined;
356
- /**
357
- * Tag names of elements to serialize without closing tag (default: `html-void-elements`).
358
- *
359
- * Not used in the SVG space.
360
- *
361
- * > 👉 **Note**: It’s highly unlikely that you want to pass this, because
362
- * > hast is not for XML, and HTML will not add more void elements.
363
- */
364
- voids?: ReadonlyArray<string> | null | undefined;
365
- };
366
- /**
367
- * HTML quotes for attribute values.
368
- */
369
- type Quote = "\"" | "'";
370
- /**
371
- * Namespace.
372
- */
373
- type Space = "html" | "svg";
374
-
375
134
  /**
376
135
  * Get highlighted code in HTML.
377
136
  */
@@ -474,4 +233,4 @@ declare function createPositionConverter(code: string): {
474
233
  posToIndex: (line: number, character: number) => number;
475
234
  };
476
235
 
477
- export { BundledHighlighterOptions, CodeToHastOptions, CodeToHastRenderOptions, CodeToTokensBaseOptions, CodeToTokensOptions, CodeToTokensWithThemesOptions, type CreateHighlighterFactory, CreatedBundledHighlighterOptions, GrammarState, HighlighterCore, HighlighterCoreOptions, HighlighterGeneric, JavaScriptRegexEngineOptions, LanguageInput, LoadWasmOptions, MaybeArray, MaybeGetter, PlainTextLanguage, Position, RegexEngine, RequireKeys, ShikiError, ShikiInternal, ShikiTransformer, ShikiTransformerContextCommon, ShikiTransformerContextSource, type ShorthandsBundle, SpecialLanguage, SpecialTheme, ThemeInput, ThemeRegistrationAny, ThemeRegistrationResolved, ThemedToken, ThemedTokenWithVariants, TokenStyles, TokenizeWithThemeOptions, TokensResult, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighterCore, createHighlighterCoreSync, createJavaScriptRegexEngine, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createWasmOnigEngine, createdBundledHighlighter, defaultJavaScriptRegexConstructor, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, toHtml as hastToHtml, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, loadWasm, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, setDefaultWasmLoader, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations };
236
+ export { type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighterCore, createHighlighterCoreSync, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createdBundledHighlighter, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, setDefaultWasmLoader, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations };
@@ -0,0 +1,236 @@
1
+ import { CreatedBundledHighlighterOptions, CreateHighlighterFactory, LanguageInput, ThemeInput, HighlighterCoreOptions, CodeToHastOptions, CodeToTokensOptions, TokensResult, RequireKeys, CodeToTokensBaseOptions, ThemedToken, CodeToTokensWithThemesOptions, ThemedTokenWithVariants, BundledHighlighterOptions, HighlighterGeneric, GrammarState, HighlighterCore, ShikiInternal, LoadWasmOptions, ShikiTransformerContextCommon, CodeToHastRenderOptions, ShikiTransformerContextSource, ThemeRegistrationResolved, TokenizeWithThemeOptions, ThemeRegistrationAny, ShikiTransformer, MaybeArray, PlainTextLanguage, SpecialLanguage, SpecialTheme, MaybeGetter, TokenStyles, Position } from '@shikijs/types';
2
+ export * from '@shikijs/types';
3
+ import { Root, Element } from 'hast';
4
+ export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from '@shikijs/engine-javascript';
5
+ import { IGrammar } from '@shikijs/vscode-textmate';
6
+ export { FontStyle, EncodedTokenMetadata as StackElementMetadata } from '@shikijs/vscode-textmate';
7
+ export { createWasmOnigEngine, loadWasm } from '@shikijs/engine-oniguruma';
8
+ export { toHtml as hastToHtml } from 'hast-util-to-html';
9
+
10
+ /**
11
+ * Create a `createHighlighter` function with bundled themes, languages, and engine.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * const createHighlighter = createdBundledHighlighter({
16
+ * langs: {
17
+ * typescript: () => import('shiki/langs/typescript.mjs'),
18
+ * // ...
19
+ * },
20
+ * themes: {
21
+ * nord: () => import('shiki/themes/nord.mjs'),
22
+ * // ...
23
+ * },
24
+ * engine: () => createWasmOnigEngine(), // or createJavaScriptRegexEngine()
25
+ * })
26
+ * ```
27
+ *
28
+ * @param options
29
+ */
30
+ declare function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(options: CreatedBundledHighlighterOptions<BundledLangs, BundledThemes>): CreateHighlighterFactory<BundledLangs, BundledThemes>;
31
+ /**
32
+ * Create a `createHighlighter` function with bundled themes and languages.
33
+ *
34
+ * @deprecated Use `createdBundledHighlighter({ langs, themes, engine })` signature instead.
35
+ */
36
+ declare function createdBundledHighlighter<BundledLangs extends string, BundledThemes extends string>(bundledLanguages: Record<BundledLangs, LanguageInput>, bundledThemes: Record<BundledThemes, ThemeInput>, loadWasm: HighlighterCoreOptions['loadWasm']): CreateHighlighterFactory<BundledLangs, BundledThemes>;
37
+ interface ShorthandsBundle<L extends string, T extends string> {
38
+ /**
39
+ * Shorthand for `codeToHtml` with auto-loaded theme and language.
40
+ * A singleton highlighter it maintained internally.
41
+ *
42
+ * Differences from `highlighter.codeToHtml()`, this function is async.
43
+ */
44
+ codeToHtml: (code: string, options: CodeToHastOptions<L, T>) => Promise<string>;
45
+ /**
46
+ * Shorthand for `codeToHtml` with auto-loaded theme and language.
47
+ * A singleton highlighter it maintained internally.
48
+ *
49
+ * Differences from `highlighter.codeToHtml()`, this function is async.
50
+ */
51
+ codeToHast: (code: string, options: CodeToHastOptions<L, T>) => Promise<Root>;
52
+ /**
53
+ * Shorthand for `codeToTokens` with auto-loaded theme and language.
54
+ * A singleton highlighter it maintained internally.
55
+ *
56
+ * Differences from `highlighter.codeToTokens()`, this function is async.
57
+ */
58
+ codeToTokens: (code: string, options: CodeToTokensOptions<L, T>) => Promise<TokensResult>;
59
+ /**
60
+ * Shorthand for `codeToTokensBase` with auto-loaded theme and language.
61
+ * A singleton highlighter it maintained internally.
62
+ *
63
+ * Differences from `highlighter.codeToTokensBase()`, this function is async.
64
+ */
65
+ codeToTokensBase: (code: string, options: RequireKeys<CodeToTokensBaseOptions<L, T>, 'theme' | 'lang'>) => Promise<ThemedToken[][]>;
66
+ /**
67
+ * Shorthand for `codeToTokensWithThemes` with auto-loaded theme and language.
68
+ * A singleton highlighter it maintained internally.
69
+ *
70
+ * Differences from `highlighter.codeToTokensWithThemes()`, this function is async.
71
+ */
72
+ codeToTokensWithThemes: (code: string, options: RequireKeys<CodeToTokensWithThemesOptions<L, T>, 'themes' | 'lang'>) => Promise<ThemedTokenWithVariants[][]>;
73
+ /**
74
+ * Get the singleton highlighter.
75
+ */
76
+ getSingletonHighlighter: (options?: Partial<BundledHighlighterOptions<L, T>>) => Promise<HighlighterGeneric<L, T>>;
77
+ /**
78
+ * Shorthand for `getLastGrammarState` with auto-loaded theme and language.
79
+ * A singleton highlighter it maintained internally.
80
+ */
81
+ getLastGrammarState: (code: string, options: CodeToTokensBaseOptions<L, T>) => Promise<GrammarState>;
82
+ }
83
+ declare function makeSingletonHighlighter<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>): (options?: Partial<BundledHighlighterOptions<L, T>>) => Promise<HighlighterGeneric<L, T>>;
84
+ declare function createSingletonShorthands<L extends string, T extends string>(createHighlighter: CreateHighlighterFactory<L, T>): ShorthandsBundle<L, T>;
85
+
86
+ /**
87
+ * Create a Shiki core highlighter instance, with no languages or themes bundled.
88
+ * Wasm and each language and theme must be loaded manually.
89
+ *
90
+ * @see http://shiki.style/guide/bundles#fine-grained-bundle
91
+ */
92
+ declare function createHighlighterCore(options?: HighlighterCoreOptions): Promise<HighlighterCore>;
93
+ /**
94
+ * Create a Shiki core highlighter instance, with no languages or themes bundled.
95
+ * Wasm and each language and theme must be loaded manually.
96
+ *
97
+ * Synchronous version of `createHighlighterCore`, which requires to provide the engine and all themes and languages upfront.
98
+ *
99
+ * @see http://shiki.style/guide/bundles#fine-grained-bundle
100
+ */
101
+ declare function createHighlighterCoreSync(options?: HighlighterCoreOptions<true>): HighlighterCore;
102
+ declare function makeSingletonHighlighterCore(createHighlighter: typeof createHighlighterCore): (options?: Partial<HighlighterCoreOptions>) => Promise<HighlighterCore>;
103
+ declare const getSingletonHighlighterCore: (options?: Partial<HighlighterCoreOptions>) => Promise<HighlighterCore>;
104
+ /**
105
+ * @deprecated Use `createHighlighterCore` or `getSingletonHighlighterCore` instead.
106
+ */
107
+ declare function getHighlighterCore(options?: HighlighterCoreOptions): Promise<HighlighterCore>;
108
+
109
+ /**
110
+ * Get the minimal shiki context for rendering.
111
+ */
112
+ declare function createShikiInternal(options?: HighlighterCoreOptions): Promise<ShikiInternal>;
113
+ /**
114
+ * @deprecated Use `createShikiInternal` instead.
115
+ */
116
+ declare function getShikiInternal(options?: HighlighterCoreOptions): Promise<ShikiInternal>;
117
+
118
+ /**
119
+ * Get the minimal shiki context for rendering.
120
+ *
121
+ * Synchronous version of `createShikiInternal`, which requires to provide the engine and all themes and languages upfront.
122
+ */
123
+ declare function createShikiInternalSync(options: HighlighterCoreOptions<true>): ShikiInternal;
124
+
125
+ /**
126
+ * Set the default wasm loader for `loadWasm`.
127
+ * @internal
128
+ */
129
+ declare function setDefaultWasmLoader(_loader: LoadWasmOptions): void;
130
+
131
+ declare function codeToHast(internal: ShikiInternal, code: string, options: CodeToHastOptions, transformerContext?: ShikiTransformerContextCommon): Root;
132
+ declare function tokensToHast(tokens: ThemedToken[][], options: CodeToHastRenderOptions, transformerContext: ShikiTransformerContextSource): Root;
133
+
134
+ /**
135
+ * Get highlighted code in HTML.
136
+ */
137
+ declare function codeToHtml(internal: ShikiInternal, code: string, options: CodeToHastOptions): string;
138
+
139
+ /**
140
+ * High-level code-to-tokens API.
141
+ *
142
+ * It will use `codeToTokensWithThemes` or `codeToTokensBase` based on the options.
143
+ */
144
+ declare function codeToTokens(internal: ShikiInternal, code: string, options: CodeToTokensOptions): TokensResult;
145
+
146
+ declare function tokenizeAnsiWithTheme(theme: ThemeRegistrationResolved, fileContents: string, options?: TokenizeWithThemeOptions): ThemedToken[][];
147
+
148
+ /**
149
+ * Code to tokens, with a simple theme.
150
+ */
151
+ declare function codeToTokensBase(internal: ShikiInternal, code: string, options?: CodeToTokensBaseOptions): ThemedToken[][];
152
+ declare function tokenizeWithTheme(code: string, grammar: IGrammar, theme: ThemeRegistrationResolved, colorMap: string[], options: TokenizeWithThemeOptions): ThemedToken[][];
153
+
154
+ /**
155
+ * Get tokens with multiple themes
156
+ */
157
+ declare function codeToTokensWithThemes(internal: ShikiInternal, code: string, options: CodeToTokensWithThemesOptions): ThemedTokenWithVariants[][];
158
+
159
+ /**
160
+ * Normalize a textmate theme to shiki theme
161
+ */
162
+ declare function normalizeTheme(rawTheme: ThemeRegistrationAny): ThemeRegistrationResolved;
163
+
164
+ /**
165
+ * A built-in transformer to add decorations to the highlighted code.
166
+ */
167
+ declare function transformerDecorations(): ShikiTransformer;
168
+
169
+ declare function toArray<T>(x: MaybeArray<T>): T[];
170
+ /**
171
+ * Split a string into lines, each line preserves the line ending.
172
+ */
173
+ declare function splitLines(code: string, preserveEnding?: boolean): [string, number][];
174
+ /**
175
+ * Check if the language is plaintext that is ignored by Shiki.
176
+ *
177
+ * Hard-coded plain text languages: `plaintext`, `txt`, `text`, `plain`.
178
+ */
179
+ declare function isPlainLang(lang: string | null | undefined): lang is PlainTextLanguage;
180
+ /**
181
+ * Check if the language is specially handled or bypassed by Shiki.
182
+ *
183
+ * Hard-coded languages: `ansi` and plaintexts like `plaintext`, `txt`, `text`, `plain`.
184
+ */
185
+ declare function isSpecialLang(lang: any): lang is SpecialLanguage;
186
+ /**
187
+ * Check if the theme is specially handled or bypassed by Shiki.
188
+ *
189
+ * Hard-coded themes: `none`.
190
+ */
191
+ declare function isNoneTheme(theme: string | ThemeInput | null | undefined): theme is 'none';
192
+ /**
193
+ * Check if the theme is specially handled or bypassed by Shiki.
194
+ *
195
+ * Hard-coded themes: `none`.
196
+ */
197
+ declare function isSpecialTheme(theme: string | ThemeInput | null | undefined): theme is SpecialTheme;
198
+ /**
199
+ * Utility to append class to a hast node
200
+ *
201
+ * If the `property.class` is a string, it will be splitted by space and converted to an array.
202
+ */
203
+ declare function addClassToHast(node: Element, className: string | string[]): Element;
204
+ /**
205
+ * Split a token into multiple tokens by given offsets.
206
+ *
207
+ * The offsets are relative to the token, and should be sorted.
208
+ */
209
+ declare function splitToken<T extends Pick<ThemedToken, 'content' | 'offset'>>(token: T, offsets: number[]): T[];
210
+ /**
211
+ * Split 2D tokens array by given breakpoints.
212
+ */
213
+ declare function splitTokens<T extends Pick<ThemedToken, 'content' | 'offset'>>(tokens: T[][], breakpoints: number[] | Set<number>): T[][];
214
+ /**
215
+ * Normalize a getter to a promise.
216
+ */
217
+ declare function normalizeGetter<T>(p: MaybeGetter<T>): Promise<T>;
218
+ declare function resolveColorReplacements(theme: ThemeRegistrationAny | string, options?: TokenizeWithThemeOptions): {
219
+ [x: string]: string;
220
+ };
221
+ declare function applyColorReplacements(color: string, replacements?: Record<string, string>): string;
222
+ declare function applyColorReplacements(color?: string | undefined, replacements?: Record<string, string>): string | undefined;
223
+ declare function getTokenStyleObject(token: TokenStyles): Record<string, string>;
224
+ declare function stringifyTokenStyle(token: Record<string, string>): string;
225
+ /**
226
+ * Creates a converter between index and position in a code block.
227
+ *
228
+ * Overflow/underflow are unchecked.
229
+ */
230
+ declare function createPositionConverter(code: string): {
231
+ lines: string[];
232
+ indexToPos: (index: number) => Position;
233
+ posToIndex: (line: number, character: number) => number;
234
+ };
235
+
236
+ export { type ShorthandsBundle, addClassToHast, applyColorReplacements, codeToHast, codeToHtml, codeToTokens, codeToTokensBase, codeToTokensWithThemes, createHighlighterCore, createHighlighterCoreSync, createPositionConverter, createShikiInternal, createShikiInternalSync, createSingletonShorthands, createdBundledHighlighter, getHighlighterCore, getShikiInternal, getSingletonHighlighterCore, getTokenStyleObject, isNoneTheme, isPlainLang, isSpecialLang, isSpecialTheme, makeSingletonHighlighter, makeSingletonHighlighterCore, normalizeGetter, normalizeTheme, resolveColorReplacements, setDefaultWasmLoader, splitLines, splitToken, splitTokens, stringifyTokenStyle, toArray, tokenizeAnsiWithTheme, tokenizeWithTheme, tokensToHast, transformerDecorations };