react-shiki 0.9.3 → 0.10.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.
@@ -0,0 +1,515 @@
1
+ import { ReactElement } from "react";
2
+ import { BundledHighlighterOptions, BundledLanguage, BundledTheme, CodeOptionsMultipleThemes, CodeToHastOptions, Highlighter, HighlighterCore, LanguageRegistration, SpecialLanguage, StringLiteralUnion, ThemeRegistrationAny } from "shiki";
3
+
4
+ //#region ../node_modules/.pnpm/@types+unist@3.0.3/node_modules/@types/unist/index.d.ts
5
+ // ## Interfaces
6
+ /**
7
+ * Info associated with nodes by the ecosystem.
8
+ *
9
+ * This space is guaranteed to never be specified by unist or specifications
10
+ * implementing unist.
11
+ * But you can use it in utilities and plugins to store data.
12
+ *
13
+ * This type can be augmented to register custom data.
14
+ * For example:
15
+ *
16
+ * ```ts
17
+ * declare module 'unist' {
18
+ * interface Data {
19
+ * // `someNode.data.myId` is typed as `number | undefined`
20
+ * myId?: number | undefined
21
+ * }
22
+ * }
23
+ * ```
24
+ */
25
+ interface Data$1 {}
26
+ /**
27
+ * One place in a source file.
28
+ */
29
+ interface Point {
30
+ /**
31
+ * Line in a source file (1-indexed integer).
32
+ */
33
+ line: number;
34
+ /**
35
+ * Column in a source file (1-indexed integer).
36
+ */
37
+ column: number;
38
+ /**
39
+ * Character in a source file (0-indexed integer).
40
+ */
41
+ offset?: number | undefined;
42
+ }
43
+ /**
44
+ * Position of a node in a source document.
45
+ *
46
+ * A position is a range between two points.
47
+ */
48
+ interface Position {
49
+ /**
50
+ * Place of the first character of the parsed source region.
51
+ */
52
+ start: Point;
53
+ /**
54
+ * Place of the first character after the parsed source region.
55
+ */
56
+ end: Point;
57
+ }
58
+ /**
59
+ * Abstract unist node.
60
+ *
61
+ * The syntactic unit in unist syntax trees are called nodes.
62
+ *
63
+ * This interface is supposed to be extended.
64
+ * If you can use {@link Literal} or {@link Parent}, you should.
65
+ * But for example in markdown, a `thematicBreak` (`***`), is neither literal
66
+ * nor parent, but still a node.
67
+ */
68
+ interface Node$1 {
69
+ /**
70
+ * Node type.
71
+ */
72
+ type: string;
73
+ /**
74
+ * Info from the ecosystem.
75
+ */
76
+ data?: Data$1 | undefined;
77
+ /**
78
+ * Position of a node in a source document.
79
+ *
80
+ * Nodes that are generated (not in the original source document) must not
81
+ * have a position.
82
+ */
83
+ position?: Position | undefined;
84
+ }
85
+ //#endregion
86
+ //#region ../node_modules/.pnpm/@types+hast@3.0.4/node_modules/@types/hast/index.d.ts
87
+ // ## Interfaces
88
+ /**
89
+ * Info associated with hast nodes by the ecosystem.
90
+ *
91
+ * This space is guaranteed to never be specified by unist or hast.
92
+ * But you can use it in utilities and plugins to store data.
93
+ *
94
+ * This type can be augmented to register custom data.
95
+ * For example:
96
+ *
97
+ * ```ts
98
+ * declare module 'hast' {
99
+ * interface Data {
100
+ * // `someNode.data.myId` is typed as `number | undefined`
101
+ * myId?: number | undefined
102
+ * }
103
+ * }
104
+ * ```
105
+ */
106
+ interface Data extends Data$1 {}
107
+ /**
108
+ * Info associated with an element.
109
+ */
110
+ interface Properties {
111
+ [PropertyName: string]: boolean | number | string | null | undefined | Array<string | number>;
112
+ }
113
+ // ## Content maps
114
+ /**
115
+ * Union of registered hast nodes that can occur in {@link Element}.
116
+ *
117
+ * To register mote custom hast nodes, add them to {@link ElementContentMap}.
118
+ * They will be automatically added here.
119
+ */
120
+ type ElementContent = ElementContentMap[keyof ElementContentMap];
121
+ /**
122
+ * Registry of all hast nodes that can occur as children of {@link Element}.
123
+ *
124
+ * For a union of all {@link Element} children, see {@link ElementContent}.
125
+ */
126
+ interface ElementContentMap {
127
+ comment: Comment;
128
+ element: Element$1;
129
+ text: Text;
130
+ }
131
+ /**
132
+ * Union of registered hast nodes that can occur in {@link Root}.
133
+ *
134
+ * To register custom hast nodes, add them to {@link RootContentMap}.
135
+ * They will be automatically added here.
136
+ */
137
+ type RootContent = RootContentMap[keyof RootContentMap];
138
+ /**
139
+ * Registry of all hast nodes that can occur as children of {@link Root}.
140
+ *
141
+ * > 👉 **Note**: {@link Root} does not need to be an entire document.
142
+ * > it can also be a fragment.
143
+ *
144
+ * For a union of all {@link Root} children, see {@link RootContent}.
145
+ */
146
+ interface RootContentMap {
147
+ comment: Comment;
148
+ doctype: Doctype;
149
+ element: Element$1;
150
+ text: Text;
151
+ }
152
+ // ## Abstract nodes
153
+ /**
154
+ * Abstract hast node.
155
+ *
156
+ * This interface is supposed to be extended.
157
+ * If you can use {@link Literal} or {@link Parent}, you should.
158
+ * But for example in HTML, a `Doctype` is neither literal nor parent, but
159
+ * still a node.
160
+ *
161
+ * To register custom hast nodes, add them to {@link RootContentMap} and other
162
+ * places where relevant (such as {@link ElementContentMap}).
163
+ *
164
+ * For a union of all registered hast nodes, see {@link Nodes}.
165
+ */
166
+ interface Node extends Node$1 {
167
+ /**
168
+ * Info from the ecosystem.
169
+ */
170
+ data?: Data | undefined;
171
+ }
172
+ /**
173
+ * Abstract hast node that contains the smallest possible value.
174
+ *
175
+ * This interface is supposed to be extended if you make custom hast nodes.
176
+ *
177
+ * For a union of all registered hast literals, see {@link Literals}.
178
+ */
179
+ interface Literal extends Node {
180
+ /**
181
+ * Plain-text value.
182
+ */
183
+ value: string;
184
+ }
185
+ /**
186
+ * Abstract hast node that contains other hast nodes (*children*).
187
+ *
188
+ * This interface is supposed to be extended if you make custom hast nodes.
189
+ *
190
+ * For a union of all registered hast parents, see {@link Parents}.
191
+ */
192
+ interface Parent extends Node {
193
+ /**
194
+ * List of children.
195
+ */
196
+ children: RootContent[];
197
+ }
198
+ // ## Concrete nodes
199
+ /**
200
+ * HTML comment.
201
+ */
202
+ interface Comment extends Literal {
203
+ /**
204
+ * Node type of HTML comments in hast.
205
+ */
206
+ type: "comment";
207
+ /**
208
+ * Data associated with the comment.
209
+ */
210
+ data?: CommentData | undefined;
211
+ }
212
+ /**
213
+ * Info associated with hast comments by the ecosystem.
214
+ */
215
+ interface CommentData extends Data {}
216
+ /**
217
+ * HTML document type.
218
+ */
219
+ interface Doctype extends Node$1 {
220
+ /**
221
+ * Node type of HTML document types in hast.
222
+ */
223
+ type: "doctype";
224
+ /**
225
+ * Data associated with the doctype.
226
+ */
227
+ data?: DoctypeData | undefined;
228
+ }
229
+ /**
230
+ * Info associated with hast doctypes by the ecosystem.
231
+ */
232
+ interface DoctypeData extends Data {}
233
+ /**
234
+ * HTML element.
235
+ */
236
+ interface Element$1 extends Parent {
237
+ /**
238
+ * Node type of elements.
239
+ */
240
+ type: "element";
241
+ /**
242
+ * Tag name (such as `'body'`) of the element.
243
+ */
244
+ tagName: string;
245
+ /**
246
+ * Info associated with the element.
247
+ */
248
+ properties: Properties;
249
+ /**
250
+ * Children of element.
251
+ */
252
+ children: ElementContent[];
253
+ /**
254
+ * When the `tagName` field is `'template'`, a `content` field can be
255
+ * present.
256
+ */
257
+ content?: Root | undefined;
258
+ /**
259
+ * Data associated with the element.
260
+ */
261
+ data?: ElementData | undefined;
262
+ }
263
+ /**
264
+ * Info associated with hast elements by the ecosystem.
265
+ */
266
+ interface ElementData extends Data {}
267
+ /**
268
+ * Document fragment or a whole document.
269
+ *
270
+ * Should be used as the root of a tree and must not be used as a child.
271
+ *
272
+ * Can also be used as the value for the content field on a `'template'` element.
273
+ */
274
+ interface Root extends Parent {
275
+ /**
276
+ * Node type of hast root.
277
+ */
278
+ type: "root";
279
+ /**
280
+ * Children of root.
281
+ */
282
+ children: RootContent[];
283
+ /**
284
+ * Data associated with the hast root.
285
+ */
286
+ data?: RootData | undefined;
287
+ }
288
+ /**
289
+ * Info associated with hast root nodes by the ecosystem.
290
+ */
291
+ interface RootData extends Data {}
292
+ /**
293
+ * HTML character data (plain text).
294
+ */
295
+ interface Text extends Literal {
296
+ /**
297
+ * Node type of HTML character data (plain text) in hast.
298
+ */
299
+ type: "text";
300
+ /**
301
+ * Data associated with the text.
302
+ */
303
+ data?: TextData | undefined;
304
+ }
305
+ /**
306
+ * Info associated with hast texts by the ecosystem.
307
+ */
308
+ interface TextData extends Data {}
309
+ //#endregion
310
+ //#region src/lib/types.d.ts
311
+ /**
312
+ * HTML Element, use to type `node` from react-markdown
313
+ */
314
+ type Element = Element$1;
315
+ /**
316
+ * A Shiki BundledLanguage or a custom textmate grammar object
317
+ * @see https://shiki.style/languages
318
+ */
319
+ type Language = LanguageRegistration | StringLiteralUnion<BundledLanguage> | SpecialLanguage | undefined;
320
+ type MultiThemeKey = 'dark' | 'light' | (string & {});
321
+ /**
322
+ * A Shiki BundledTheme or a custom textmate theme object
323
+ * @see https://shiki.style/themes
324
+ */
325
+ type Theme = ThemeRegistrationAny | StringLiteralUnion<BundledTheme>;
326
+ /**
327
+ * A map of color names to themes.
328
+ * This allows you to specify multiple themes for the generated code.
329
+ * Supports custom textmate theme objects in addition to Shiki's bundled themes
330
+ *
331
+ * @example
332
+ * ```ts
333
+ * useShikiHighlighter(code, language, {
334
+ * light: 'github-light',
335
+ * dark: 'github-dark',
336
+ * dim: 'github-dark-dimmed'
337
+ * })
338
+ * ```
339
+ *
340
+ * @see https://shiki.style/guide/dual-themes
341
+ */
342
+ type Themes = { [Key in MultiThemeKey]: Theme };
343
+ /**
344
+ * Configuration options specific to react-shiki
345
+ */
346
+ interface ReactShikiOptions {
347
+ /**
348
+ * Minimum time (in milliseconds) between highlight operations.
349
+ * @default undefined (no throttling)
350
+ */
351
+ delay?: number;
352
+ /**
353
+ * Custom textmate grammars to be preloaded for highlighting.
354
+ * @deprecated Use preloadLanguages instead.
355
+ */
356
+ customLanguages?: LanguageRegistration | LanguageRegistration[];
357
+ /**
358
+ * Preload custom grammars or bundled languages.
359
+ * Supports custom textmate grammars, replaces deprecated `customLanguages`
360
+ */
361
+ preloadLanguages?: Language | Language[];
362
+ /**
363
+ * Output format for the highlighted code.
364
+ * - 'react': Returns React nodes (default, safer)
365
+ * - 'html': Returns HTML string (~15-45% faster, requires dangerouslySetInnerHTML)
366
+ * @default 'react'
367
+ */
368
+ outputFormat?: 'react' | 'html';
369
+ /**
370
+ * Custom Shiki highlighter instance to use instead of the default one.
371
+ * Keeps bundle small by only importing specified languages/themes.
372
+ * Can be either a Highlighter or HighlighterCore instance.
373
+ *
374
+ * @example
375
+ * import {
376
+ * createHighlighterCore,
377
+ * createOnigurumaEngine,
378
+ * useShikiHighlighter
379
+ * } from "react-shiki";
380
+ *
381
+ * const customHighlighter = await createHighlighterCore({
382
+ * themes: [
383
+ * import('@shikijs/themes/nord')
384
+ * ],
385
+ * langs: [
386
+ * import('@shikijs/langs/javascript'),
387
+ * import('@shikijs/langs/typescript')
388
+ * ],
389
+ * engine: createOnigurumaEngine(import('shiki/wasm'))
390
+ * });
391
+ *
392
+ * const highlightedCode = useShikiHighlighter(code, language, theme, {
393
+ * highlighter: customHighlighter,
394
+ * });
395
+ */
396
+ highlighter?: Highlighter | HighlighterCore;
397
+ /**
398
+ * Whether to show line numbers
399
+ * @default false
400
+ */
401
+ showLineNumbers?: boolean;
402
+ /**
403
+ * Starting line number (when showLineNumbers is true)
404
+ * @default 1
405
+ */
406
+ startingLineNumber?: number;
407
+ }
408
+ /**
409
+ * Configuration options for the syntax highlighter
410
+ * Extends CodeToHastOptions to allow passing any Shiki options directly
411
+ */
412
+ interface HighlighterOptions extends ReactShikiOptions, Pick<CodeOptionsMultipleThemes<BundledTheme>, 'defaultColor' | 'cssVariablePrefix'>, Omit<CodeToHastOptions, 'lang' | 'theme' | 'themes'>, Pick<BundledHighlighterOptions<string, string>, 'langAlias' | 'engine'> {}
413
+ /**
414
+ * State for the throttling logic
415
+ */
416
+ /**
417
+ * Public API signature for the useShikiHighlighter hook.
418
+ */
419
+ type HighlightedCode = ReactElement | string | null;
420
+ type UseShikiHighlighter = (code: string, lang: Language, themeInput: Theme | Themes, options?: HighlighterOptions) => HighlightedCode;
421
+ //#endregion
422
+ //#region src/lib/plugins.d.ts
423
+ /**
424
+ * Rehype plugin to add an 'inline' property to <code> elements
425
+ * Sets 'inline' property to true if the <code> is not within a <pre> tag
426
+ *
427
+ * Pass this plugin to the `rehypePlugins` prop of react-markdown
428
+ * You can then access `inline` as a prop in components passed to react-markdown
429
+ *
430
+ * @example
431
+ * <ReactMarkdown rehypePlugins={[rehypeInlineCodeProperty]} />
432
+ */
433
+ declare function rehypeInlineCodeProperty(): (tree: Root) => undefined;
434
+ /**
435
+ * Function to determine if code is inline based on the presence of line breaks
436
+ *
437
+ * @example
438
+ * const isInline = node && isInlineCode(node: Element)
439
+ */
440
+ declare const isInlineCode: (node: Element) => boolean;
441
+ //#endregion
442
+ //#region src/lib/component.d.ts
443
+ /**
444
+ * Props for the ShikiHighlighter component
445
+ */
446
+ interface ShikiHighlighterProps extends HighlighterOptions {
447
+ /**
448
+ * The programming language for syntax highlighting
449
+ * Supports custom textmate grammar objects in addition to Shiki's bundled languages
450
+ * @see https://shiki.style/languages
451
+ */
452
+ language: Language;
453
+ /**
454
+ * The code to be highlighted
455
+ */
456
+ children: string;
457
+ /**
458
+ * The color theme or themes for syntax highlighting
459
+ * Supports single, dual, or multiple themes
460
+ * Supports custom textmate theme objects in addition to Shiki's bundled themes
461
+ *
462
+ * @example
463
+ * theme='github-dark' // single theme
464
+ * theme={{ light: 'github-light', dark: 'github-dark' }} // multi-theme
465
+ *
466
+ * @see https://shiki.style/themes
467
+ */
468
+ theme: Theme | Themes;
469
+ /**
470
+ * Controls the application of default styles to the generated code blocks
471
+ *
472
+ * Default styles include padding, overflow handling, border radius, language label styling, and font settings
473
+ * @default true
474
+ */
475
+ addDefaultStyles?: boolean;
476
+ /**
477
+ * Add custom inline styles to the generated code block
478
+ */
479
+ style?: React.CSSProperties;
480
+ /**
481
+ * Add custom inline styles to the language label
482
+ */
483
+ langStyle?: React.CSSProperties;
484
+ /**
485
+ * Add custom CSS class names to the generated code block
486
+ */
487
+ className?: string;
488
+ /**
489
+ * Add custom CSS class names to the language label
490
+ */
491
+ langClassName?: string;
492
+ /**
493
+ * Whether to show the language label
494
+ * @default true
495
+ */
496
+ showLanguage?: boolean;
497
+ /**
498
+ * Whether to show line numbers
499
+ * @default false
500
+ */
501
+ showLineNumbers?: boolean;
502
+ /**
503
+ * Starting line number (when showLineNumbers is true)
504
+ * @default 1
505
+ */
506
+ startingLineNumber?: number;
507
+ /**
508
+ * The HTML element that wraps the generated code block.
509
+ * @default 'div'
510
+ */
511
+ as?: React.ElementType;
512
+ }
513
+ //#endregion
514
+ export { HighlighterOptions as a, Themes as c, Element as i, UseShikiHighlighter as l, isInlineCode as n, Language as o, rehypeInlineCodeProperty as r, Theme as s, ShikiHighlighterProps as t };
515
+ //# sourceMappingURL=component-CjpuWrgO.d.mts.map
@@ -1,12 +1,10 @@
1
- import * as react from 'react';
2
- import { S as ShikiHighlighterProps, U as UseShikiHighlighter } from './component-CoSKNtmy.js';
3
- export { E as Element, H as HighlighterOptions, L as Language, T as Theme, a as Themes, i as isInlineCode, r as rehypeInlineCodeProperty } from './component-CoSKNtmy.js';
4
- export { LanguageRegistration, createHighlighterCore } from 'shiki/core';
5
- export { createOnigurumaEngine } from 'shiki/engine/oniguruma';
6
- export { createJavaScriptRawEngine, createJavaScriptRegexEngine } from 'shiki/engine/javascript';
7
- import 'shiki';
8
- import 'hast';
1
+ import { a as HighlighterOptions, c as Themes, i as Element, l as UseShikiHighlighter, n as isInlineCode, o as Language, r as rehypeInlineCodeProperty, s as Theme, t as ShikiHighlighterProps } from "./component-CjpuWrgO.mjs";
2
+ import * as _$react from "react";
3
+ import { LanguageRegistration, createHighlighterCore } from "shiki/core";
4
+ import { createOnigurumaEngine } from "shiki/engine/oniguruma";
5
+ import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
9
6
 
7
+ //#region src/core.d.ts
10
8
  /**
11
9
  * Highlight code with shiki (core bundle)
12
10
  *
@@ -45,6 +43,7 @@ declare const useShikiHighlighter: UseShikiHighlighter;
45
43
  * ShikiHighlighter component using a custom highlighter.
46
44
  * Requires a highlighter to be provided.
47
45
  */
48
- declare const ShikiHighlighter: react.ForwardRefExoticComponent<ShikiHighlighterProps & react.RefAttributes<HTMLElement>>;
49
-
50
- export { ShikiHighlighter, ShikiHighlighterProps, UseShikiHighlighter, ShikiHighlighter as default, useShikiHighlighter };
46
+ declare const ShikiHighlighter: _$react.ForwardRefExoticComponent<ShikiHighlighterProps & _$react.RefAttributes<HTMLElement>>;
47
+ //#endregion
48
+ export { type Element, type HighlighterOptions, type Language, type LanguageRegistration, ShikiHighlighter, ShikiHighlighter as default, type ShikiHighlighterProps, type Theme, type Themes, type UseShikiHighlighter, createHighlighterCore, createJavaScriptRawEngine, createJavaScriptRegexEngine, createOnigurumaEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
49
+ //# sourceMappingURL=core.d.mts.map
package/dist/core.mjs ADDED
@@ -0,0 +1,64 @@
1
+ import { i as useHighlight, n as isInlineCode, r as rehypeInlineCodeProperty, t as createShikiHighlighterComponent } from "./component-C5lsWZSq.mjs";
2
+ import { createHighlighterCore } from "shiki/core";
3
+ import { createOnigurumaEngine } from "shiki/engine/oniguruma";
4
+ import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
5
+ //#region src/bundles/core.ts
6
+ /**
7
+ * Validates that a highlighter is provided for the core bundle.
8
+ * The core bundle requires users to provide their own highlighter instance.
9
+ */
10
+ function validateCoreHighlighter(highlighter) {
11
+ if (!highlighter) throw new Error("react-shiki/core requires a custom highlighter. Use createHighlighterCore() from react-shiki or switch to react-shiki for plug-and-play usage.");
12
+ return highlighter;
13
+ }
14
+ //#endregion
15
+ //#region src/core.ts
16
+ /**
17
+ * Highlight code with shiki (core bundle)
18
+ *
19
+ * @param code - Code to highlight
20
+ * @param lang - Language (bundled or custom)
21
+ * @param theme - Theme (bundled, multi-theme, or custom)
22
+ * @param options - react-shiki options + shiki options
23
+ * @returns Highlighted code as React elements or HTML string
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * import { createHighlighterCore, createOnigurumaEngine } from 'react-shiki/core';
28
+ *
29
+ *
30
+ * const highlighter = await createHighlighterCore({
31
+ * themes: [import('@shikijs/themes/github-light'), import('@shikijs/themes/github-dark')],
32
+ * langs: [import('@shikijs/langs/typescript')],
33
+ * engine: createOnigurumaEngine(import('shiki/wasm'))
34
+ * });
35
+ *
36
+ * const highlighted = useShikiHighlighter(
37
+ * 'const x = 1;',
38
+ * 'typescript',
39
+ * {
40
+ * light: 'github-light',
41
+ * dark: 'github-dark'
42
+ * },
43
+ * { highlighter }
44
+ * );
45
+ * ```
46
+ *
47
+ * Core bundle (minimal). For plug-and-play: `react-shiki` or `react-shiki/web`
48
+ */
49
+ const useShikiHighlighter = (code, lang, themeInput, options = {}) => {
50
+ const highlighter = validateCoreHighlighter(options.highlighter);
51
+ return useHighlight(code, lang, themeInput, {
52
+ ...options,
53
+ highlighter
54
+ }, async () => highlighter);
55
+ };
56
+ /**
57
+ * ShikiHighlighter component using a custom highlighter.
58
+ * Requires a highlighter to be provided.
59
+ */
60
+ const ShikiHighlighter = createShikiHighlighterComponent(useShikiHighlighter);
61
+ //#endregion
62
+ export { ShikiHighlighter, ShikiHighlighter as default, createHighlighterCore, createJavaScriptRawEngine, createJavaScriptRegexEngine, createOnigurumaEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
63
+
64
+ //# sourceMappingURL=core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.mjs","names":[],"sources":["../src/bundles/core.ts","../src/core.ts"],"sourcesContent":["import type { HighlighterCore } from 'shiki';\n\n/**\n * Validates that a highlighter is provided for the core bundle.\n * The core bundle requires users to provide their own highlighter instance.\n */\nexport function validateCoreHighlighter(\n highlighter: HighlighterCore | undefined\n): HighlighterCore {\n if (!highlighter) {\n throw new Error(\n 'react-shiki/core requires a custom highlighter. ' +\n 'Use createHighlighterCore() from react-shiki or switch to react-shiki for plug-and-play usage.'\n );\n }\n return highlighter;\n}\n","import { useHighlight } from './lib/hook';\nimport { validateCoreHighlighter } from './bundles/core';\nimport type { UseShikiHighlighter } from './lib/types';\n\nexport { isInlineCode, rehypeInlineCodeProperty } from './lib/plugins';\n\nimport {\n createShikiHighlighterComponent,\n type ShikiHighlighterProps,\n} from './lib/component';\n\nexport type { ShikiHighlighterProps };\n\nexport type {\n UseShikiHighlighter,\n Language,\n Theme,\n Themes,\n Element,\n HighlighterOptions,\n} from './lib/types';\n\nexport { createHighlighterCore } from 'shiki/core';\nexport { createOnigurumaEngine } from 'shiki/engine/oniguruma';\nexport {\n createJavaScriptRegexEngine,\n createJavaScriptRawEngine,\n} from 'shiki/engine/javascript';\n\nexport type { LanguageRegistration } from 'shiki/core';\n\n/**\n * Highlight code with shiki (core bundle)\n *\n * @param code - Code to highlight\n * @param lang - Language (bundled or custom)\n * @param theme - Theme (bundled, multi-theme, or custom)\n * @param options - react-shiki options + shiki options\n * @returns Highlighted code as React elements or HTML string\n *\n * @example\n * ```tsx\n * import { createHighlighterCore, createOnigurumaEngine } from 'react-shiki/core';\n *\n *\n * const highlighter = await createHighlighterCore({\n * themes: [import('@shikijs/themes/github-light'), import('@shikijs/themes/github-dark')],\n * langs: [import('@shikijs/langs/typescript')],\n * engine: createOnigurumaEngine(import('shiki/wasm'))\n * });\n *\n * const highlighted = useShikiHighlighter(\n * 'const x = 1;',\n * 'typescript',\n * {\n * light: 'github-light',\n * dark: 'github-dark'\n * },\n * { highlighter }\n * );\n * ```\n *\n * Core bundle (minimal). For plug-and-play: `react-shiki` or `react-shiki/web`\n */\nexport const useShikiHighlighter: UseShikiHighlighter = (\n code,\n lang,\n themeInput,\n options = {}\n) => {\n // Validate that highlighter is provided\n const highlighter = validateCoreHighlighter(options.highlighter);\n\n return useHighlight(\n code,\n lang,\n themeInput,\n {\n ...options,\n highlighter,\n },\n async () => highlighter\n );\n};\n\n/**\n * ShikiHighlighter component using a custom highlighter.\n * Requires a highlighter to be provided.\n */\nexport const ShikiHighlighter = createShikiHighlighterComponent(\n useShikiHighlighter\n);\nexport default ShikiHighlighter;\n"],"mappings":";;;;;;;;;AAMA,SAAgB,wBACd,aACiB;AACjB,KAAI,CAAC,YACH,OAAM,IAAI,MACR,iJAED;AAEH,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACiDT,MAAa,uBACX,MACA,MACA,YACA,UAAU,EAAE,KACT;CAEH,MAAM,cAAc,wBAAwB,QAAQ,YAAY;AAEhE,QAAO,aACL,MACA,MACA,YACA;EACE,GAAG;EACH;EACD,EACD,YAAY,YACb;;;;;;AAOH,MAAa,mBAAmB,gCAC9B,oBACD"}
@@ -0,0 +1,38 @@
1
+ import { a as HighlighterOptions, c as Themes, i as Element, l as UseShikiHighlighter, n as isInlineCode, o as Language, r as rehypeInlineCodeProperty, s as Theme, t as ShikiHighlighterProps } from "./component-CjpuWrgO.mjs";
2
+ import * as _$react from "react";
3
+ import { LanguageRegistration } from "shiki";
4
+ import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
5
+
6
+ //#region src/index.d.ts
7
+ /**
8
+ * Highlight code with shiki (full bundle)
9
+ *
10
+ * @param code - Code to highlight
11
+ * @param lang - Language (bundled or custom)
12
+ * @param theme - Theme (bundled, multi-theme, or custom)
13
+ * @param options - react-shiki options + shiki options
14
+ * @returns Highlighted code as React elements or HTML string
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * const highlighted = useShikiHighlighter(
19
+ * 'const x = 1;',
20
+ * 'typescript',
21
+ * {
22
+ * light: 'github-light',
23
+ * dark: 'github-dark'
24
+ * }
25
+ * );
26
+ * ```
27
+ *
28
+ * Full bundle (~6.4MB minified, 1.2MB gzipped). For smaller bundles: `react-shiki/web` or `react-shiki/core`
29
+ */
30
+ declare const useShikiHighlighter: UseShikiHighlighter;
31
+ /**
32
+ * ShikiHighlighter component using the full bundle.
33
+ * Includes all languages and themes for maximum compatibility.
34
+ */
35
+ declare const ShikiHighlighter: _$react.ForwardRefExoticComponent<ShikiHighlighterProps & _$react.RefAttributes<HTMLElement>>;
36
+ //#endregion
37
+ export { type Element, type HighlighterOptions, type Language, type LanguageRegistration, ShikiHighlighter, ShikiHighlighter as default, type ShikiHighlighterProps, type Theme, type Themes, type UseShikiHighlighter, createJavaScriptRawEngine, createJavaScriptRegexEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
38
+ //# sourceMappingURL=index.d.mts.map