react-shiki 0.11.0 → 0.11.2
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/README.md +228 -111
- package/dist/{component-DdW14SOw.mjs → component-Cf8Topxy.mjs} +118 -78
- package/dist/component-Cf8Topxy.mjs.map +1 -0
- package/dist/component-DRPT3D6t.d.mts +1200 -0
- package/dist/core.d.mts +4 -5
- package/dist/core.mjs +2 -2
- package/dist/core.mjs.map +1 -1
- package/dist/factory-DySLHBEo.mjs +17 -0
- package/dist/factory-DySLHBEo.mjs.map +1 -0
- package/dist/index.d.mts +4 -5
- package/dist/index.mjs +6 -12
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -68
- package/dist/web.d.mts +4 -5
- package/dist/web.mjs +7 -13
- package/dist/web.mjs.map +1 -1
- package/package.json +24 -20
- package/dist/component-B-gutZRK.d.mts +0 -546
- package/dist/component-DdW14SOw.mjs.map +0 -1
- package/src/styles/features.css +0 -54
package/dist/core.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as EngineName, c as HighlighterOptionsFor, d as PreloadLanguage, f as Theme, i as Element, l as Language, m as UseShikiHighlighter, n as isInlineCode, o as HighlightResult, p as Themes, r as rehypeInlineCodeProperty, s as HighlighterOptions, t as ShikiHighlighterProps, u as OutputFormat } from "./component-DRPT3D6t.mjs";
|
|
2
2
|
import { LanguageRegistration, TokensResult, createHighlighterCore } from "shiki/core";
|
|
3
3
|
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
4
4
|
import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
5
|
-
|
|
6
5
|
//#region src/core.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Highlight code with shiki (core bundle)
|
|
@@ -37,12 +36,12 @@ import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/en
|
|
|
37
36
|
*
|
|
38
37
|
* Core bundle (minimal). For plug-and-play: `react-shiki` or `react-shiki/web`
|
|
39
38
|
*/
|
|
40
|
-
declare const useShikiHighlighter: UseShikiHighlighter;
|
|
39
|
+
export declare const useShikiHighlighter: UseShikiHighlighter;
|
|
41
40
|
/**
|
|
42
41
|
* ShikiHighlighter component using a custom highlighter.
|
|
43
42
|
* Requires a highlighter to be provided.
|
|
44
43
|
*/
|
|
45
|
-
declare const ShikiHighlighter: import("react").ForwardRefExoticComponent<ShikiHighlighterProps & import("react").RefAttributes<HTMLElement>>;
|
|
44
|
+
export declare const ShikiHighlighter: import("react").ForwardRefExoticComponent<ShikiHighlighterProps & import("react").RefAttributes<HTMLElement>>;
|
|
46
45
|
//#endregion
|
|
47
|
-
export { type Element, type HighlightResult, type HighlighterOptions, type HighlighterOptionsFor, type Language, type LanguageRegistration, type OutputFormat,
|
|
46
|
+
export { type Element, type EngineName, type HighlightResult, type HighlighterOptions, type HighlighterOptionsFor, type Language, type LanguageRegistration, type OutputFormat, type PreloadLanguage, ShikiHighlighter as default, type ShikiHighlighterProps, type Theme, type Themes, type TokensResult, type UseShikiHighlighter, createHighlighterCore, createJavaScriptRawEngine, createJavaScriptRegexEngine, createOnigurumaEngine, isInlineCode, rehypeInlineCodeProperty };
|
|
48
47
|
//# sourceMappingURL=core.d.mts.map
|
package/dist/core.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as useHighlight, n as isInlineCode, r as rehypeInlineCodeProperty, t as createShikiHighlighterComponent } from "./component-
|
|
1
|
+
import { i as useHighlight, n as isInlineCode, r as rehypeInlineCodeProperty, t as createShikiHighlighterComponent } from "./component-Cf8Topxy.mjs";
|
|
2
2
|
import { createHighlighterCore } from "shiki/core";
|
|
3
3
|
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
4
4
|
import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
@@ -57,7 +57,7 @@ const useShikiHighlighter = (code, lang, themeInput, options = {}) => {
|
|
|
57
57
|
* ShikiHighlighter component using a custom highlighter.
|
|
58
58
|
* Requires a highlighter to be provided.
|
|
59
59
|
*/
|
|
60
|
-
const ShikiHighlighter = createShikiHighlighterComponent(useShikiHighlighter);
|
|
60
|
+
const ShikiHighlighter = /*#__PURE__*/ createShikiHighlighterComponent(useShikiHighlighter);
|
|
61
61
|
//#endregion
|
|
62
62
|
export { ShikiHighlighter, ShikiHighlighter as default, createHighlighterCore, createJavaScriptRawEngine, createJavaScriptRegexEngine, createOnigurumaEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
|
|
63
63
|
|
package/dist/core.mjs.map
CHANGED
|
@@ -1 +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 HighlighterOptionsFor,\n HighlightResult,\n OutputFormat,\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, TokensResult } 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 (default), HTML string, or Shiki tokens, based on `outputFormat`\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
|
|
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 PreloadLanguage,\n Theme,\n Themes,\n Element,\n EngineName,\n HighlighterOptions,\n HighlighterOptionsFor,\n HighlightResult,\n OutputFormat,\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, TokensResult } 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 (default), HTML string, or Shiki tokens, based on `outputFormat`\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 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 =\n /*#__PURE__*/ createShikiHighlighterComponent(useShikiHighlighter);\nexport default ShikiHighlighter;\n"],"mappings":";;;;;;;;;AAMA,SAAgB,wBACd,aACiB;CACjB,IAAI,CAAC,aACH,MAAM,IAAI,MACR,gJAEF;CAEF,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqDA,MAAa,uBACX,MACA,MACA,YACA,UAAU,CAAC,MACR;CACH,MAAM,cAAc,wBAAwB,QAAQ,WAAW;CAE/D,OAAO,aACL,MACA,MACA,YACA;EACE,GAAG;EACH;CACF,GACA,YAAY,WACd;AACF;;;;;AAMA,MAAa,mBACG,8CAAgC,mBAAmB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { a as isLoadableLanguage } from "./component-Cf8Topxy.mjs";
|
|
2
|
+
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
3
|
+
//#region src/bundles/factory.ts
|
|
4
|
+
/**
|
|
5
|
+
* Builds a highlighter factory for a Shiki bundle (full or web).
|
|
6
|
+
* Unloadable languages are filtered out so unknown ids fall back to
|
|
7
|
+
* plaintext instead of throwing.
|
|
8
|
+
*/
|
|
9
|
+
const bundledHighlighterFactory = (getSingletonHighlighter, bundledLanguages) => (langsToLoad, themesToLoad, engine) => getSingletonHighlighter({
|
|
10
|
+
langs: langsToLoad.filter((lang) => isLoadableLanguage(lang, bundledLanguages)),
|
|
11
|
+
themes: themesToLoad,
|
|
12
|
+
engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { bundledHighlighterFactory as t };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=factory-DySLHBEo.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory-DySLHBEo.mjs","names":[],"sources":["../src/bundles/factory.ts"],"sourcesContent":["import { createOnigurumaEngine } from 'shiki/engine/oniguruma';\nimport type {\n Awaitable,\n DynamicImportLanguageRegistration,\n HighlighterCore,\n RegexEngine,\n} from 'shiki/core';\nimport type {\n HighlighterFactory,\n PreloadLanguage,\n Theme,\n} from '../lib/types';\nimport { isLoadableLanguage } from '../lib/language';\n\ntype GetSingletonHighlighter = (options: {\n langs: NonNullable<PreloadLanguage>[];\n themes: Theme[];\n engine: Awaitable<RegexEngine>;\n}) => Promise<HighlighterCore>;\n\n/**\n * Builds a highlighter factory for a Shiki bundle (full or web).\n * Unloadable languages are filtered out so unknown ids fall back to\n * plaintext instead of throwing.\n */\nexport const bundledHighlighterFactory =\n (\n getSingletonHighlighter: GetSingletonHighlighter,\n bundledLanguages: Record<string, DynamicImportLanguageRegistration>\n ): HighlighterFactory =>\n (langsToLoad, themesToLoad, engine) =>\n getSingletonHighlighter({\n langs: langsToLoad.filter((lang) =>\n isLoadableLanguage(lang, bundledLanguages)\n ),\n themes: themesToLoad,\n engine: engine ?? createOnigurumaEngine(import('shiki/wasm')),\n });\n"],"mappings":";;;;;;;;AAyBA,MAAa,6BAET,yBACA,sBAED,aAAa,cAAc,WAC1B,wBAAwB;CACtB,OAAO,YAAY,QAAQ,SACzB,mBAAmB,MAAM,gBAAgB,CAC3C;CACA,QAAQ;CACR,QAAQ,UAAU,sBAAsB,OAAO,aAAa;AAC9D,CAAC"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as EngineName, c as HighlighterOptionsFor, d as PreloadLanguage, f as Theme, i as Element, l as Language, m as UseShikiHighlighter, n as isInlineCode, o as HighlightResult, p as Themes, r as rehypeInlineCodeProperty, s as HighlighterOptions, t as ShikiHighlighterProps, u as OutputFormat } from "./component-DRPT3D6t.mjs";
|
|
2
2
|
import { LanguageRegistration, TokensResult } from "shiki";
|
|
3
3
|
import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
4
|
-
|
|
5
4
|
//#region src/index.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Highlight code with shiki (full bundle)
|
|
@@ -26,12 +25,12 @@ import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/en
|
|
|
26
25
|
*
|
|
27
26
|
* Full bundle (~6.4MB minified, 1.2MB gzipped). For smaller bundles: `react-shiki/web` or `react-shiki/core`
|
|
28
27
|
*/
|
|
29
|
-
declare const useShikiHighlighter: UseShikiHighlighter;
|
|
28
|
+
export declare const useShikiHighlighter: UseShikiHighlighter;
|
|
30
29
|
/**
|
|
31
30
|
* ShikiHighlighter component using the full bundle.
|
|
32
31
|
* Includes all languages and themes for maximum compatibility.
|
|
33
32
|
*/
|
|
34
|
-
declare const ShikiHighlighter: import("react").ForwardRefExoticComponent<ShikiHighlighterProps & import("react").RefAttributes<HTMLElement>>;
|
|
33
|
+
export declare const ShikiHighlighter: import("react").ForwardRefExoticComponent<ShikiHighlighterProps & import("react").RefAttributes<HTMLElement>>;
|
|
35
34
|
//#endregion
|
|
36
|
-
export { type Element, type HighlightResult, type HighlighterOptions, type HighlighterOptionsFor, type Language, type LanguageRegistration, type OutputFormat,
|
|
35
|
+
export { type Element, type EngineName, type HighlightResult, type HighlighterOptions, type HighlighterOptionsFor, type Language, type LanguageRegistration, type OutputFormat, type PreloadLanguage, ShikiHighlighter as default, type ShikiHighlighterProps, type Theme, type Themes, type TokensResult, type UseShikiHighlighter, createJavaScriptRawEngine, createJavaScriptRegexEngine, isInlineCode, rehypeInlineCodeProperty };
|
|
37
36
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as useHighlight, n as isInlineCode, r as rehypeInlineCodeProperty, t as createShikiHighlighterComponent } from "./component-Cf8Topxy.mjs";
|
|
2
|
+
import { t as bundledHighlighterFactory } from "./factory-DySLHBEo.mjs";
|
|
2
3
|
import { bundledLanguages, getSingletonHighlighter } from "shiki";
|
|
3
|
-
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
4
4
|
import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
5
5
|
//#region src/bundles/full.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Highlighter factory for the full Shiki bundle: every language and
|
|
8
|
+
* theme, largest size, maximum compatibility.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
return await getSingletonHighlighter({
|
|
12
|
-
langs: langsToLoad.filter((lang) => isLoadableLanguage(lang, bundledLanguages)),
|
|
13
|
-
themes: themesToLoad,
|
|
14
|
-
engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
|
|
15
|
-
});
|
|
16
|
-
}
|
|
10
|
+
const createFullHighlighter = bundledHighlighterFactory(getSingletonHighlighter, bundledLanguages);
|
|
17
11
|
//#endregion
|
|
18
12
|
//#region src/index.ts
|
|
19
13
|
/**
|
|
@@ -44,7 +38,7 @@ const useShikiHighlighter = (code, lang, themeInput, options = {}) => useHighlig
|
|
|
44
38
|
* ShikiHighlighter component using the full bundle.
|
|
45
39
|
* Includes all languages and themes for maximum compatibility.
|
|
46
40
|
*/
|
|
47
|
-
const ShikiHighlighter = createShikiHighlighterComponent(useShikiHighlighter);
|
|
41
|
+
const ShikiHighlighter = /*#__PURE__*/ createShikiHighlighterComponent(useShikiHighlighter);
|
|
48
42
|
//#endregion
|
|
49
43
|
export { ShikiHighlighter, ShikiHighlighter as default, createJavaScriptRawEngine, createJavaScriptRegexEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
|
|
50
44
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/bundles/full.ts","../src/index.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/bundles/full.ts","../src/index.ts"],"sourcesContent":["import { getSingletonHighlighter, bundledLanguages } from 'shiki';\nimport { bundledHighlighterFactory } from './factory';\n\n/**\n * Highlighter factory for the full Shiki bundle: every language and\n * theme, largest size, maximum compatibility.\n */\nexport const createFullHighlighter = bundledHighlighterFactory(\n getSingletonHighlighter,\n bundledLanguages\n);\n","import { useHighlight } from './lib/hook';\nimport { createFullHighlighter } from './bundles/full';\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 PreloadLanguage,\n Theme,\n Themes,\n Element,\n EngineName,\n HighlighterOptions,\n HighlighterOptionsFor,\n HighlightResult,\n OutputFormat,\n} from './lib/types';\n\nexport {\n createJavaScriptRegexEngine,\n createJavaScriptRawEngine,\n} from 'shiki/engine/javascript';\n\nexport type { LanguageRegistration, TokensResult } from 'shiki';\n\n/**\n * Highlight code with shiki (full 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 (default), HTML string, or Shiki tokens, based on `outputFormat`\n *\n * @example\n * ```tsx\n * const highlighted = useShikiHighlighter(\n * 'const x = 1;',\n * 'typescript',\n * {\n * light: 'github-light',\n * dark: 'github-dark'\n * }\n * );\n * ```\n *\n * Full bundle (~6.4MB minified, 1.2MB gzipped). For smaller bundles: `react-shiki/web` or `react-shiki/core`\n */\nexport const useShikiHighlighter: UseShikiHighlighter = (\n code,\n lang,\n themeInput,\n options = {}\n) => useHighlight(code, lang, themeInput, options, createFullHighlighter);\n\n/**\n * ShikiHighlighter component using the full bundle.\n * Includes all languages and themes for maximum compatibility.\n */\nexport const ShikiHighlighter =\n /*#__PURE__*/ createShikiHighlighterComponent(useShikiHighlighter);\nexport default ShikiHighlighter;\n"],"mappings":";;;;;;;;;AAOA,MAAa,wBAAwB,0BACnC,yBACA,gBACF;;;;;;;;;;;;;;;;;;;;;;;;;;AC+CA,MAAa,uBACX,MACA,MACA,YACA,UAAU,CAAC,MACR,aAAa,MAAM,MAAM,YAAY,SAAS,qBAAqB;;;;;AAMxE,MAAa,mBACG,8CAAgC,mBAAmB"}
|
package/dist/style.css
CHANGED
|
@@ -1,68 +1 @@
|
|
|
1
|
-
:where(.rs-root) {
|
|
2
|
-
position: relative;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
:where(.rs-root.rs-default-styles) pre {
|
|
6
|
-
border-radius: .5rem;
|
|
7
|
-
padding-block: 1.25rem;
|
|
8
|
-
padding-inline: 1.5rem;
|
|
9
|
-
overflow: auto;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
:where(.rs-root) .rs-language-label {
|
|
13
|
-
z-index: 1;
|
|
14
|
-
letter-spacing: -.05em;
|
|
15
|
-
color: #6b7280d9;
|
|
16
|
-
font-family: monospace;
|
|
17
|
-
font-size: .75rem;
|
|
18
|
-
position: absolute;
|
|
19
|
-
top: .5rem;
|
|
20
|
-
right: .75rem;
|
|
21
|
-
}
|
|
22
|
-
:where(.rs-has-line-numbers) {
|
|
23
|
-
counter-reset: line-number calc(var(--line-start, 1) - 1);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
:where(.rs-has-line-numbers .rs-line-number):before {
|
|
27
|
-
counter-increment: line-number;
|
|
28
|
-
content: counter(line-number);
|
|
29
|
-
box-sizing: content-box;
|
|
30
|
-
min-width: var(--rs-line-numbers-width, 2ch);
|
|
31
|
-
padding-left: var(--rs-line-numbers-padding-left, 0ch);
|
|
32
|
-
padding-right: var(--rs-line-numbers-padding-right, 2ch);
|
|
33
|
-
color: var(--rs-line-numbers-foreground, #6b728080);
|
|
34
|
-
font-size: var(--rs-line-numbers-font-size, inherit);
|
|
35
|
-
font-weight: var(--rs-line-numbers-font-weight, inherit);
|
|
36
|
-
line-height: var(--rs-line-numbers-line-height, inherit);
|
|
37
|
-
font-family: var(--rs-line-numbers-font-family, inherit);
|
|
38
|
-
opacity: var(--rs-line-numbers-opacity, 1);
|
|
39
|
-
user-select: none;
|
|
40
|
-
pointer-events: none;
|
|
41
|
-
justify-content: flex-end;
|
|
42
|
-
align-items: flex-start;
|
|
43
|
-
display: inline-flex;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
:where(.rs-has-highlighted-lines) {
|
|
47
|
-
width: fit-content;
|
|
48
|
-
min-width: 100%;
|
|
49
|
-
display: block;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
:where(.rs-highlighted-line) {
|
|
53
|
-
--_rs-hl-background: var(--rs-highlighted-line-background, color-mix(in srgb, currentColor 10%, transparent));
|
|
54
|
-
background-color: var(--_rs-hl-background);
|
|
55
|
-
width: 100%;
|
|
56
|
-
min-height: 1lh;
|
|
57
|
-
display: inline-block;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
:where(.rs-default-styles) .rs-highlighted-line {
|
|
61
|
-
border-image: linear-gradient(var(--_rs-hl-background) 0 0) fill 0 / 0 / 0
|
|
62
|
-
100vw;
|
|
63
|
-
background-color: #0000;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
:where(.rs-has-line-numbers .rs-highlighted-line):before {
|
|
67
|
-
color: var(--rs-highlighted-line-number-foreground, color-mix(in srgb, currentColor 65%, transparent));
|
|
68
|
-
}
|
|
1
|
+
:where(.rs-root){position:relative}:where(.rs-root.rs-default-styles pre){border-radius:.5rem;padding-block:1.25rem;padding-inline:1.5rem;overflow:auto}:where(.rs-root .rs-language-label){z-index:1;letter-spacing:-.05em;color:#6b7280d9;font-family:monospace;font-size:.75rem;position:absolute;top:.5rem;right:.75rem}:where(.rs-has-line-numbers){counter-reset:line-number calc(var(--line-start,1) - 1)}:where(.rs-has-line-numbers .rs-line-number):before{counter-increment:line-number;content:counter(line-number);box-sizing:content-box;min-width:var(--rs-line-numbers-width,2ch);padding-left:var(--rs-line-numbers-padding-left,0ch);padding-right:var(--rs-line-numbers-padding-right,2ch);color:var(--rs-line-numbers-foreground,#6b728080);font-size:var(--rs-line-numbers-font-size,inherit);font-weight:var(--rs-line-numbers-font-weight,inherit);line-height:var(--rs-line-numbers-line-height,inherit);font-family:var(--rs-line-numbers-font-family,inherit);opacity:var(--rs-line-numbers-opacity,1);user-select:none;pointer-events:none;justify-content:flex-end;align-items:flex-start;display:inline-flex}:where(.rs-has-highlighted-lines){width:fit-content;min-width:100%;display:block}:where(.rs-highlighted-line){--_rs-hl-background:var(--rs-highlighted-line-background,color-mix(in srgb, currentColor 10%, transparent));background-color:var(--_rs-hl-background);width:100%;min-height:1lh;display:inline-block}:where(.rs-default-styles .rs-highlighted-line){border-image:linear-gradient(var(--_rs-hl-background) 0 0) fill 0 / 0 / 0 100vw;background-color:#0000}:where(.rs-has-line-numbers .rs-highlighted-line):before{color:var(--rs-highlighted-line-number-foreground,color-mix(in srgb, currentColor 65%, transparent))}
|
package/dist/web.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as EngineName, c as HighlighterOptionsFor, d as PreloadLanguage, f as Theme, i as Element, l as Language, m as UseShikiHighlighter, n as isInlineCode, o as HighlightResult, p as Themes, r as rehypeInlineCodeProperty, s as HighlighterOptions, t as ShikiHighlighterProps, u as OutputFormat } from "./component-DRPT3D6t.mjs";
|
|
2
2
|
import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
3
3
|
import { LanguageRegistration, TokensResult } from "shiki/bundle/web";
|
|
4
|
-
|
|
5
4
|
//#region src/web.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Highlight code with shiki (web bundle)
|
|
@@ -26,12 +25,12 @@ import { LanguageRegistration, TokensResult } from "shiki/bundle/web";
|
|
|
26
25
|
*
|
|
27
26
|
* Web bundle (~3.8MB minified, 695KB gzipped). For other bundles: `react-shiki` or `react-shiki/core`
|
|
28
27
|
*/
|
|
29
|
-
declare const useShikiHighlighter: UseShikiHighlighter;
|
|
28
|
+
export declare const useShikiHighlighter: UseShikiHighlighter;
|
|
30
29
|
/**
|
|
31
30
|
* ShikiHighlighter component using the web bundle.
|
|
32
31
|
* Includes web-focused languages for balanced size and functionality.
|
|
33
32
|
*/
|
|
34
|
-
declare const ShikiHighlighter: import("react").ForwardRefExoticComponent<ShikiHighlighterProps & import("react").RefAttributes<HTMLElement>>;
|
|
33
|
+
export declare const ShikiHighlighter: import("react").ForwardRefExoticComponent<ShikiHighlighterProps & import("react").RefAttributes<HTMLElement>>;
|
|
35
34
|
//#endregion
|
|
36
|
-
export { type Element, type HighlightResult, type HighlighterOptions, type HighlighterOptionsFor, type Language, type LanguageRegistration, type OutputFormat,
|
|
35
|
+
export { type Element, type EngineName, type HighlightResult, type HighlighterOptions, type HighlighterOptionsFor, type Language, type LanguageRegistration, type OutputFormat, type PreloadLanguage, ShikiHighlighter as default, type ShikiHighlighterProps, type Theme, type Themes, type TokensResult, type UseShikiHighlighter, createJavaScriptRawEngine, createJavaScriptRegexEngine, isInlineCode, rehypeInlineCodeProperty };
|
|
37
36
|
//# sourceMappingURL=web.d.mts.map
|
package/dist/web.mjs
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { i as useHighlight, n as isInlineCode, r as rehypeInlineCodeProperty, t as createShikiHighlighterComponent } from "./component-Cf8Topxy.mjs";
|
|
2
|
+
import { t as bundledHighlighterFactory } from "./factory-DySLHBEo.mjs";
|
|
3
3
|
import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
4
4
|
import { bundledLanguages, getSingletonHighlighter } from "shiki/bundle/web";
|
|
5
5
|
//#region src/bundles/web.ts
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Highlighter factory for the web Shiki bundle: web-focused languages
|
|
8
|
+
* (HTML, CSS, JS, TS, JSON, Markdown, Vue, JSX, Svelte, etc.) at a
|
|
9
|
+
* fraction of the full bundle's size.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
return await getSingletonHighlighter({
|
|
13
|
-
langs: langsToLoad.filter((lang) => isLoadableLanguage(lang, bundledLanguages)),
|
|
14
|
-
themes: themesToLoad,
|
|
15
|
-
engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
|
|
16
|
-
});
|
|
17
|
-
}
|
|
11
|
+
const createWebHighlighter = bundledHighlighterFactory(getSingletonHighlighter, bundledLanguages);
|
|
18
12
|
//#endregion
|
|
19
13
|
//#region src/web.ts
|
|
20
14
|
/**
|
|
@@ -45,7 +39,7 @@ const useShikiHighlighter = (code, lang, themeInput, options = {}) => useHighlig
|
|
|
45
39
|
* ShikiHighlighter component using the web bundle.
|
|
46
40
|
* Includes web-focused languages for balanced size and functionality.
|
|
47
41
|
*/
|
|
48
|
-
const ShikiHighlighter = createShikiHighlighterComponent(useShikiHighlighter);
|
|
42
|
+
const ShikiHighlighter = /*#__PURE__*/ createShikiHighlighterComponent(useShikiHighlighter);
|
|
49
43
|
//#endregion
|
|
50
44
|
export { ShikiHighlighter, ShikiHighlighter as default, createJavaScriptRawEngine, createJavaScriptRegexEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
|
|
51
45
|
|
package/dist/web.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.mjs","names":[],"sources":["../src/bundles/web.ts","../src/web.ts"],"sourcesContent":["import {\n getSingletonHighlighter,\n bundledLanguages,\n
|
|
1
|
+
{"version":3,"file":"web.mjs","names":[],"sources":["../src/bundles/web.ts","../src/web.ts"],"sourcesContent":["import {\n getSingletonHighlighter,\n bundledLanguages,\n} from 'shiki/bundle/web';\nimport { bundledHighlighterFactory } from './factory';\n\n/**\n * Highlighter factory for the web Shiki bundle: web-focused languages\n * (HTML, CSS, JS, TS, JSON, Markdown, Vue, JSX, Svelte, etc.) at a\n * fraction of the full bundle's size.\n */\nexport const createWebHighlighter = bundledHighlighterFactory(\n getSingletonHighlighter,\n bundledLanguages\n);\n","import { useHighlight } from './lib/hook';\nimport { createWebHighlighter } from './bundles/web';\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 PreloadLanguage,\n Theme,\n Themes,\n Element,\n EngineName,\n HighlighterOptions,\n HighlighterOptionsFor,\n HighlightResult,\n OutputFormat,\n} from './lib/types';\n\nexport {\n createJavaScriptRegexEngine,\n createJavaScriptRawEngine,\n} from 'shiki/engine/javascript';\n\nexport type {\n LanguageRegistration,\n TokensResult,\n} from 'shiki/bundle/web';\n\n/**\n * Highlight code with shiki (web 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 (default), HTML string, or Shiki tokens, based on `outputFormat`\n *\n * @example\n * ```tsx\n * const highlighted = useShikiHighlighter(\n * 'const x = 1;',\n * 'typescript',\n * {\n * light: 'github-light',\n * dark: 'github-dark'\n * }\n * );\n * ```\n *\n * Web bundle (~3.8MB minified, 695KB gzipped). For other bundles: `react-shiki` or `react-shiki/core`\n */\nexport const useShikiHighlighter: UseShikiHighlighter = (\n code,\n lang,\n themeInput,\n options = {}\n) => useHighlight(code, lang, themeInput, options, createWebHighlighter);\n\n/**\n * ShikiHighlighter component using the web bundle.\n * Includes web-focused languages for balanced size and functionality.\n */\nexport const ShikiHighlighter =\n /*#__PURE__*/ createShikiHighlighterComponent(useShikiHighlighter);\nexport default ShikiHighlighter;\n"],"mappings":";;;;;;;;;;AAWA,MAAa,uBAAuB,0BAClC,yBACA,gBACF;;;;;;;;;;;;;;;;;;;;;;;;;;AC8CA,MAAa,uBACX,MACA,MACA,YACA,UAAU,CAAC,MACR,aAAa,MAAM,MAAM,YAAY,SAAS,oBAAoB;;;;;AAMvE,MAAa,mBACG,8CAAgC,mBAAmB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-shiki",
|
|
3
3
|
"description": "Syntax highlighter component for react using shiki",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bassim Shahidy",
|
|
@@ -28,12 +28,10 @@
|
|
|
28
28
|
"types": "./dist/index.d.mts",
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
31
|
-
"src/styles/features.css",
|
|
32
31
|
"src/styles/css.d.ts"
|
|
33
32
|
],
|
|
34
33
|
"sideEffects": [
|
|
35
|
-
"
|
|
36
|
-
"src/styles/features.css"
|
|
34
|
+
"**/*.css"
|
|
37
35
|
],
|
|
38
36
|
"publishConfig": {
|
|
39
37
|
"access": "public",
|
|
@@ -54,7 +52,7 @@
|
|
|
54
52
|
},
|
|
55
53
|
"./css": {
|
|
56
54
|
"types": "./src/styles/css.d.ts",
|
|
57
|
-
"default": "./
|
|
55
|
+
"default": "./dist/style.css"
|
|
58
56
|
}
|
|
59
57
|
},
|
|
60
58
|
"peerDependencies": {
|
|
@@ -75,30 +73,36 @@
|
|
|
75
73
|
"clsx": "^2.1.1",
|
|
76
74
|
"dequal": "^2.0.3",
|
|
77
75
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
78
|
-
"shiki": "^4.
|
|
76
|
+
"shiki": "^4.5.0",
|
|
79
77
|
"unist-util-visit": "^5.1.0"
|
|
80
78
|
},
|
|
81
79
|
"devDependencies": {
|
|
82
|
-
"@arethetypeswrong/core": "^0.18.
|
|
83
|
-
"@testing-library/jest-dom": "^
|
|
84
|
-
"@testing-library/react": "^16.3.
|
|
85
|
-
"@tsdown/css": "0.
|
|
86
|
-
"@types/hast": "^3.0.
|
|
80
|
+
"@arethetypeswrong/core": "^0.18.5",
|
|
81
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
82
|
+
"@testing-library/react": "^16.3.3",
|
|
83
|
+
"@tsdown/css": "^0.23.0",
|
|
84
|
+
"@types/hast": "^3.0.5",
|
|
87
85
|
"@types/jest": "^30.0.0",
|
|
88
|
-
"@types/node": "25.9.
|
|
89
|
-
"@types/react": "^19.
|
|
90
|
-
"@vitejs/plugin-react": "^6.
|
|
91
|
-
"html-react-parser": "^6.1.
|
|
92
|
-
"jsdom": "^
|
|
93
|
-
"publint": "^0.3.
|
|
94
|
-
"
|
|
95
|
-
"
|
|
86
|
+
"@types/node": "25.9.9",
|
|
87
|
+
"@types/react": "^19.3.0",
|
|
88
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
89
|
+
"html-react-parser": "^6.1.8",
|
|
90
|
+
"jsdom": "^30.1.2",
|
|
91
|
+
"publint": "^0.3.25",
|
|
92
|
+
"rolldown": "^1.2.12",
|
|
93
|
+
"tsdown": "^0.23.0",
|
|
94
|
+
"vitest": "^5.0.3",
|
|
95
|
+
"react": "^19.3.0",
|
|
96
|
+
"react-dom": "^19.3.0",
|
|
97
|
+
"@types/react-dom": "^19.3.0",
|
|
98
|
+
"@testing-library/dom": "^10.4.2"
|
|
96
99
|
},
|
|
97
100
|
"scripts": {
|
|
98
101
|
"dev": "tsdown --watch",
|
|
99
102
|
"build": "tsdown",
|
|
103
|
+
"check:package": "node scripts/check-package.mjs",
|
|
100
104
|
"test": "vitest",
|
|
101
|
-
"bench": "vitest bench",
|
|
105
|
+
"bench": "vitest bench --typecheck.enabled=false",
|
|
102
106
|
"lint": "biome lint .",
|
|
103
107
|
"lint:fix": "biome lint --write .",
|
|
104
108
|
"format": "biome format --write .",
|