react-shiki 0.9.1 → 0.9.3
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 +20 -15
- package/dist/chunk-S5E5K22S.js +424 -0
- package/dist/chunk-S5E5K22S.js.map +1 -0
- package/dist/{component-mMdHg8JD.d.ts → component-CoSKNtmy.d.ts} +8 -39
- package/dist/core.d.ts +3 -3
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +12 -18
- package/dist/index.js.map +1 -1
- package/dist/web.d.ts +3 -3
- package/dist/web.js +12 -18
- package/dist/web.js.map +1 -1
- package/package.json +20 -15
- package/src/styles/css.d.ts +1 -0
- package/src/styles/features.css +36 -0
- package/dist/chunk-EXJNTVNR.js +0 -349
- package/dist/chunk-EXJNTVNR.js.map +0 -1
- package/src/lib/styles.css +0 -55
package/dist/core.js
CHANGED
package/dist/core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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 { useShikiHighlighter as useBaseHook } 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\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 useBaseHook(\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":";;;;;;;;AAMO,SAAS,wBACd,aACiB;AACjB,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO;AACT;;;ACMA,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,OACK;
|
|
1
|
+
{"version":3,"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 { useShikiHighlighter as useBaseHook } 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 useBaseHook(\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":";;;;;;;;AAMO,SAAS,wBACd,aACiB;AACjB,MAAI,CAAC,aAAa;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,SAAO;AACT;;;ACMA,SAAS,6BAA6B;AACtC,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAqCA,IAAMA,uBAA2C,CACtD,MACA,MACA,YACA,UAAU,CAAC,MACR;AAEH,QAAM,cAAc,wBAAwB,QAAQ,WAAW;AAE/D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH;AAAA,IACF;AAAA,IACA,YAAY;AAAA,EACd;AACF;AAMO,IAAM,mBAAmB;AAAA,EAC9BA;AACF;AACA,IAAO,eAAQ;","names":["useShikiHighlighter"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { S as ShikiHighlighterProps, U as UseShikiHighlighter } from './component-
|
|
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-
|
|
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
4
|
export { createJavaScriptRawEngine, createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
5
|
-
|
|
6
|
-
import 'shiki/core';
|
|
5
|
+
export { LanguageRegistration } from 'shiki';
|
|
7
6
|
import 'hast';
|
|
8
7
|
|
|
9
8
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createShikiHighlighterComponent,
|
|
3
3
|
isInlineCode,
|
|
4
|
+
isLoadableLanguage,
|
|
4
5
|
rehypeInlineCodeProperty,
|
|
5
6
|
useShikiHighlighter
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-S5E5K22S.js";
|
|
7
8
|
|
|
8
9
|
// src/bundles/full.ts
|
|
9
10
|
import {
|
|
10
|
-
getSingletonHighlighter
|
|
11
|
+
getSingletonHighlighter,
|
|
12
|
+
bundledLanguages
|
|
11
13
|
} from "shiki";
|
|
12
14
|
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
13
15
|
async function createFullHighlighter(langsToLoad, themesToLoad, engine) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return await getSingletonHighlighter({
|
|
23
|
-
langs: ["plaintext"],
|
|
24
|
-
themes: themesToLoad,
|
|
25
|
-
engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
16
|
+
const langs = langsToLoad.filter(
|
|
17
|
+
(lang) => isLoadableLanguage(lang, bundledLanguages)
|
|
18
|
+
);
|
|
19
|
+
return await getSingletonHighlighter({
|
|
20
|
+
langs,
|
|
21
|
+
themes: themesToLoad,
|
|
22
|
+
engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
|
|
23
|
+
});
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
// src/index.ts
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bundles/full.ts","../src/index.ts"],"sourcesContent":["import {\n getSingletonHighlighter,\n type Highlighter,\n type Awaitable,\n type RegexEngine,\n} from 'shiki';\nimport { createOnigurumaEngine } from 'shiki/engine/oniguruma';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/bundles/full.ts","../src/index.ts"],"sourcesContent":["import {\n getSingletonHighlighter,\n bundledLanguages,\n type Highlighter,\n type Awaitable,\n type RegexEngine,\n} from 'shiki';\nimport { createOnigurumaEngine } from 'shiki/engine/oniguruma';\nimport type { Language, Theme } from '../lib/types';\nimport { isLoadableLanguage } from '../lib/language';\n\n/**\n * Creates a highlighter using the full Shiki bundle with all languages and themes.\n * This is the largest bundle but provides maximum compatibility.\n */\nexport async function createFullHighlighter(\n langsToLoad: Language[],\n themesToLoad: Theme[],\n engine?: Awaitable<RegexEngine>\n): Promise<Highlighter> {\n const langs = langsToLoad.filter((lang) =>\n isLoadableLanguage(lang, bundledLanguages)\n );\n\n return await getSingletonHighlighter({\n langs,\n themes: themesToLoad,\n engine: engine ?? createOnigurumaEngine(import('shiki/wasm')),\n });\n}\n","import { useShikiHighlighter as useBaseHook } 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 Theme,\n Themes,\n Element,\n HighlighterOptions,\n} from './lib/types';\n\nexport {\n createJavaScriptRegexEngine,\n createJavaScriptRawEngine,\n} from 'shiki/engine/javascript';\n\nexport type { LanguageRegistration } 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 or HTML string\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) => {\n return useBaseHook(\n code,\n lang,\n themeInput,\n options,\n createFullHighlighter\n );\n};\n\n/**\n * ShikiHighlighter component using the full bundle.\n * Includes all languages and themes for maximum compatibility.\n */\nexport const ShikiHighlighter = createShikiHighlighterComponent(\n useShikiHighlighter\n);\nexport default ShikiHighlighter;\n"],"mappings":";;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,SAAS,6BAA6B;AAQtC,eAAsB,sBACpB,aACA,cACA,QACsB;AACtB,QAAM,QAAQ,YAAY;AAAA,IAAO,CAAC,SAChC,mBAAmB,MAAM,gBAAgB;AAAA,EAC3C;AAEA,SAAO,MAAM,wBAAwB;AAAA,IACnC;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ,UAAU,sBAAsB,OAAO,YAAY,CAAC;AAAA,EAC9D,CAAC;AACH;;;ACPA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AA2BA,IAAMA,uBAA2C,CACtD,MACA,MACA,YACA,UAAU,CAAC,MACR;AACH,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAMO,IAAM,mBAAmB;AAAA,EAC9BA;AACF;AACA,IAAO,cAAQ;","names":["useShikiHighlighter"]}
|
package/dist/web.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { S as ShikiHighlighterProps, U as UseShikiHighlighter } from './component-
|
|
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-
|
|
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
4
|
export { createJavaScriptRawEngine, createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
|
5
|
+
export { LanguageRegistration } from 'shiki/bundle/web';
|
|
5
6
|
import 'shiki';
|
|
6
|
-
import 'shiki/core';
|
|
7
7
|
import 'hast';
|
|
8
8
|
|
|
9
9
|
/**
|
package/dist/web.js
CHANGED
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createShikiHighlighterComponent,
|
|
3
3
|
isInlineCode,
|
|
4
|
+
isLoadableLanguage,
|
|
4
5
|
rehypeInlineCodeProperty,
|
|
5
6
|
useShikiHighlighter
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-S5E5K22S.js";
|
|
7
8
|
|
|
8
9
|
// src/bundles/web.ts
|
|
9
10
|
import {
|
|
10
|
-
getSingletonHighlighter
|
|
11
|
+
getSingletonHighlighter,
|
|
12
|
+
bundledLanguages
|
|
11
13
|
} from "shiki/bundle/web";
|
|
12
14
|
import { createOnigurumaEngine } from "shiki/engine/oniguruma";
|
|
13
15
|
async function createWebHighlighter(langsToLoad, themesToLoad, engine) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return await getSingletonHighlighter({
|
|
23
|
-
langs: ["plaintext"],
|
|
24
|
-
themes: themesToLoad,
|
|
25
|
-
engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
16
|
+
const langs = langsToLoad.filter(
|
|
17
|
+
(lang) => isLoadableLanguage(lang, bundledLanguages)
|
|
18
|
+
);
|
|
19
|
+
return await getSingletonHighlighter({
|
|
20
|
+
langs,
|
|
21
|
+
themes: themesToLoad,
|
|
22
|
+
engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
|
|
23
|
+
});
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
// src/web.ts
|
package/dist/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bundles/web.ts","../src/web.ts"],"sourcesContent":["import {\n getSingletonHighlighter,\n type Highlighter,\n type Awaitable,\n type RegexEngine,\n} from 'shiki/bundle/web';\nimport { createOnigurumaEngine } from 'shiki/engine/oniguruma';\nimport type {
|
|
1
|
+
{"version":3,"sources":["../src/bundles/web.ts","../src/web.ts"],"sourcesContent":["import {\n getSingletonHighlighter,\n bundledLanguages,\n type Highlighter,\n type Awaitable,\n type RegexEngine,\n} from 'shiki/bundle/web';\nimport { createOnigurumaEngine } from 'shiki/engine/oniguruma';\nimport type { Language, Theme } from '../lib/types';\nimport { isLoadableLanguage } from '../lib/language';\n\n/**\n * Creates a highlighter using the web Shiki bundle with web-focused languages.\n * Smaller than the full bundle while covering most web development needs.\n * Includes: HTML, CSS, JS, TS, JSON, Markdown, Vue, JSX, Svelte, etc.\n */\nexport async function createWebHighlighter(\n langsToLoad: Language[],\n themesToLoad: Theme[],\n engine?: Awaitable<RegexEngine>\n): Promise<Highlighter> {\n const langs = langsToLoad.filter((lang) =>\n isLoadableLanguage(lang, bundledLanguages)\n );\n\n return await getSingletonHighlighter({\n langs,\n themes: themesToLoad,\n engine: engine ?? createOnigurumaEngine(import('shiki/wasm')),\n });\n}\n","import { useShikiHighlighter as useBaseHook } 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 Theme,\n Themes,\n Element,\n HighlighterOptions,\n} from './lib/types';\n\nexport {\n createJavaScriptRegexEngine,\n createJavaScriptRawEngine,\n} from 'shiki/engine/javascript';\n\nexport type { LanguageRegistration } 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 or HTML string\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) => {\n return useBaseHook(\n code,\n lang,\n themeInput,\n options,\n createWebHighlighter\n );\n};\n\n/**\n * ShikiHighlighter component using the web bundle.\n * Includes web-focused languages for balanced size and functionality.\n */\nexport const ShikiHighlighter = createShikiHighlighterComponent(\n useShikiHighlighter\n);\nexport default ShikiHighlighter;\n"],"mappings":";;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP,SAAS,6BAA6B;AAStC,eAAsB,qBACpB,aACA,cACA,QACsB;AACtB,QAAM,QAAQ,YAAY;AAAA,IAAO,CAAC,SAChC,mBAAmB,MAAM,gBAAgB;AAAA,EAC3C;AAEA,SAAO,MAAM,wBAAwB;AAAA,IACnC;AAAA,IACA,QAAQ;AAAA,IACR,QAAQ,UAAU,sBAAsB,OAAO,YAAY,CAAC;AAAA,EAC9D,CAAC;AACH;;;ACRA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AA2BA,IAAMA,uBAA2C,CACtD,MACA,MACA,YACA,UAAU,CAAC,MACR;AACH,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAMO,IAAM,mBAAmB;AAAA,EAC9BA;AACF;AACA,IAAO,cAAQ;","names":["useShikiHighlighter"]}
|
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.9.
|
|
4
|
+
"version": "0.9.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Bassim Shahidy",
|
|
@@ -28,10 +28,12 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"files": [
|
|
30
30
|
"dist",
|
|
31
|
-
"src/
|
|
31
|
+
"src/styles/features.css",
|
|
32
|
+
"src/styles/css.d.ts"
|
|
32
33
|
],
|
|
33
34
|
"sideEffects": [
|
|
34
|
-
"src/
|
|
35
|
+
"src/styles/component.css",
|
|
36
|
+
"src/styles/features.css"
|
|
35
37
|
],
|
|
36
38
|
"publishConfig": {
|
|
37
39
|
"access": "public",
|
|
@@ -50,7 +52,10 @@
|
|
|
50
52
|
"types": "./dist/core.d.ts",
|
|
51
53
|
"default": "./dist/core.js"
|
|
52
54
|
},
|
|
53
|
-
"./css":
|
|
55
|
+
"./css": {
|
|
56
|
+
"types": "./src/styles/css.d.ts",
|
|
57
|
+
"default": "./src/styles/features.css"
|
|
58
|
+
}
|
|
54
59
|
},
|
|
55
60
|
"peerDependencies": {
|
|
56
61
|
"@types/react": ">=16.8.0",
|
|
@@ -70,21 +75,21 @@
|
|
|
70
75
|
"clsx": "^2.1.1",
|
|
71
76
|
"dequal": "^2.0.3",
|
|
72
77
|
"hast-util-to-jsx-runtime": "^2.3.6",
|
|
73
|
-
"shiki": "^
|
|
74
|
-
"unist-util-visit": "^5.
|
|
78
|
+
"shiki": "^4.0.0",
|
|
79
|
+
"unist-util-visit": "^5.1.0"
|
|
75
80
|
},
|
|
76
81
|
"devDependencies": {
|
|
77
|
-
"@testing-library/jest-dom": "^6.
|
|
78
|
-
"@testing-library/react": "^16.3.
|
|
82
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
83
|
+
"@testing-library/react": "^16.3.2",
|
|
79
84
|
"@types/hast": "^3.0.4",
|
|
80
|
-
"@types/jest": "^
|
|
81
|
-
"@types/node": "
|
|
85
|
+
"@types/jest": "^30.0.0",
|
|
86
|
+
"@types/node": "25.3.3",
|
|
82
87
|
"@types/react": "^19.1.10",
|
|
83
|
-
"@vitejs/plugin-react": "^
|
|
84
|
-
"html-react-parser": "^5.2.
|
|
85
|
-
"jsdom": "^
|
|
86
|
-
"tsup": "^8.5.
|
|
87
|
-
"vitest": "^
|
|
88
|
+
"@vitejs/plugin-react": "^5.1.4",
|
|
89
|
+
"html-react-parser": "^5.2.17",
|
|
90
|
+
"jsdom": "^28.1.0",
|
|
91
|
+
"tsup": "^8.5.1",
|
|
92
|
+
"vitest": "^4.0.18"
|
|
88
93
|
},
|
|
89
94
|
"scripts": {
|
|
90
95
|
"dev": "tsup --watch",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@layer base {
|
|
2
|
+
.line-numbers::before,
|
|
3
|
+
.rs-line-number::before {
|
|
4
|
+
counter-increment: line-number;
|
|
5
|
+
content: counter(line-number);
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
justify-content: flex-end;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
box-sizing: content-box;
|
|
10
|
+
min-width: var(--rs-line-numbers-width, 2ch);
|
|
11
|
+
padding-left: var(--rs-line-numbers-padding-left, 2ch);
|
|
12
|
+
padding-right: var(--rs-line-numbers-padding-right, 2ch);
|
|
13
|
+
color: var(--rs-line-numbers-foreground, rgba(107, 114, 128, 0.6));
|
|
14
|
+
font-size: var(--rs-line-numbers-font-size, inherit);
|
|
15
|
+
font-weight: var(--rs-line-numbers-font-weight, inherit);
|
|
16
|
+
line-height: var(--rs-line-numbers-line-height, inherit);
|
|
17
|
+
font-family: var(--rs-line-numbers-font-family, inherit);
|
|
18
|
+
opacity: var(--rs-line-numbers-opacity, 1);
|
|
19
|
+
user-select: none;
|
|
20
|
+
pointer-events: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.has-line-numbers,
|
|
24
|
+
.rs-has-line-numbers {
|
|
25
|
+
counter-reset: line-number calc(var(--line-start, 1) - 1);
|
|
26
|
+
--rs-line-numbers-foreground: var(--line-numbers-foreground, rgba(107, 114, 128, 0.5));
|
|
27
|
+
--rs-line-numbers-width: var(--line-numbers-width, 2ch);
|
|
28
|
+
--rs-line-numbers-padding-left: var(--line-numbers-padding-left, 0ch);
|
|
29
|
+
--rs-line-numbers-padding-right: var(--line-numbers-padding-right, 2ch);
|
|
30
|
+
--rs-line-numbers-font-size: var(--line-numbers-font-size, inherit);
|
|
31
|
+
--rs-line-numbers-font-weight: var(--line-numbers-font-weight, inherit);
|
|
32
|
+
--rs-line-numbers-line-height: var(--line-numbers-line-height, inherit);
|
|
33
|
+
--rs-line-numbers-font-family: var(--line-numbers-font-family, inherit);
|
|
34
|
+
--rs-line-numbers-opacity: var(--line-numbers-opacity, 1);
|
|
35
|
+
}
|
|
36
|
+
}
|
package/dist/chunk-EXJNTVNR.js
DELETED
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
// src/lib/hook.ts
|
|
2
|
-
import {
|
|
3
|
-
useEffect,
|
|
4
|
-
useMemo,
|
|
5
|
-
useRef as useRef2,
|
|
6
|
-
useState
|
|
7
|
-
} from "react";
|
|
8
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
9
|
-
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
10
|
-
|
|
11
|
-
// src/lib/utils.ts
|
|
12
|
-
import { useRef } from "react";
|
|
13
|
-
import { dequal } from "dequal";
|
|
14
|
-
var useStableOptions = (value) => {
|
|
15
|
-
const ref = useRef(value);
|
|
16
|
-
const revision = useRef(0);
|
|
17
|
-
if (typeof value !== "object" || value === null) {
|
|
18
|
-
if (value !== ref.current) {
|
|
19
|
-
ref.current = value;
|
|
20
|
-
revision.current += 1;
|
|
21
|
-
}
|
|
22
|
-
return [value, revision.current];
|
|
23
|
-
}
|
|
24
|
-
if (value !== ref.current) {
|
|
25
|
-
if (!dequal(value, ref.current)) {
|
|
26
|
-
ref.current = value;
|
|
27
|
-
revision.current += 1;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return [ref.current, revision.current];
|
|
31
|
-
};
|
|
32
|
-
var throttleHighlighting = (performHighlight, timeoutControl, throttleMs) => {
|
|
33
|
-
const now = Date.now();
|
|
34
|
-
clearTimeout(timeoutControl.current.timeoutId);
|
|
35
|
-
const delay = Math.max(0, timeoutControl.current.nextAllowedTime - now);
|
|
36
|
-
timeoutControl.current.timeoutId = setTimeout(() => {
|
|
37
|
-
performHighlight().catch(console.error);
|
|
38
|
-
timeoutControl.current.nextAllowedTime = now + throttleMs;
|
|
39
|
-
}, delay);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// src/lib/resolvers.ts
|
|
43
|
-
var resolveLanguage = (lang, customLanguages, langAliases) => {
|
|
44
|
-
const normalizedCustomLangs = customLanguages ? Array.isArray(customLanguages) ? customLanguages : [customLanguages] : [];
|
|
45
|
-
if (lang == null || typeof lang === "string" && !lang.trim()) {
|
|
46
|
-
return {
|
|
47
|
-
languageId: "plaintext",
|
|
48
|
-
displayLanguageId: "plaintext",
|
|
49
|
-
langsToLoad: void 0
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (typeof lang === "object") {
|
|
53
|
-
return {
|
|
54
|
-
languageId: lang.name,
|
|
55
|
-
displayLanguageId: lang.name || null,
|
|
56
|
-
langsToLoad: lang
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const lowerLang = lang.toLowerCase();
|
|
60
|
-
const matches = (str) => str?.toLowerCase() === lowerLang;
|
|
61
|
-
const customMatch = normalizedCustomLangs.find(
|
|
62
|
-
(cl) => matches(cl.name) || matches(cl.scopeName) || matches(cl.scopeName?.split(".").pop()) || cl.aliases?.some(matches) || cl.fileTypes?.some(matches)
|
|
63
|
-
);
|
|
64
|
-
if (customMatch) {
|
|
65
|
-
return {
|
|
66
|
-
languageId: customMatch.name || lang,
|
|
67
|
-
displayLanguageId: lang,
|
|
68
|
-
langsToLoad: customMatch
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
if (langAliases?.[lang]) {
|
|
72
|
-
return {
|
|
73
|
-
languageId: langAliases[lang],
|
|
74
|
-
displayLanguageId: lang,
|
|
75
|
-
langsToLoad: langAliases[lang]
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
languageId: lang,
|
|
80
|
-
displayLanguageId: lang,
|
|
81
|
-
langsToLoad: lang
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
var isTextmateTheme = (value) => typeof value === "object" && value !== null && "tokenColors" in value && Array.isArray(value.tokenColors);
|
|
85
|
-
function resolveTheme(themeInput) {
|
|
86
|
-
const inputIsTextmateTheme = isTextmateTheme(themeInput);
|
|
87
|
-
const isMultiThemeConfig = typeof themeInput === "object" && themeInput !== null && !inputIsTextmateTheme;
|
|
88
|
-
const validMultiThemeObj = typeof themeInput === "object" && themeInput !== null && !inputIsTextmateTheme && Object.entries(themeInput).some(
|
|
89
|
-
([key, value]) => key && value && key.trim() !== "" && value !== "" && (typeof value === "string" || isTextmateTheme(value))
|
|
90
|
-
);
|
|
91
|
-
if (isMultiThemeConfig) {
|
|
92
|
-
const themeId = validMultiThemeObj ? `multi-${Object.values(themeInput).map(
|
|
93
|
-
(theme) => (typeof theme === "string" ? theme : theme?.name) || "custom"
|
|
94
|
-
).sort().join("-")}` : "multi-default";
|
|
95
|
-
return {
|
|
96
|
-
isMultiTheme: true,
|
|
97
|
-
themeId,
|
|
98
|
-
multiTheme: validMultiThemeObj ? themeInput : null,
|
|
99
|
-
themesToLoad: validMultiThemeObj ? Object.values(themeInput) : []
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
isMultiTheme: false,
|
|
104
|
-
themeId: typeof themeInput === "string" ? themeInput : themeInput?.name || "custom",
|
|
105
|
-
singleTheme: themeInput,
|
|
106
|
-
themesToLoad: [themeInput]
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/lib/transformers.ts
|
|
111
|
-
function lineNumbersTransformer(startLine = 1) {
|
|
112
|
-
return {
|
|
113
|
-
name: "react-shiki:line-numbers",
|
|
114
|
-
code(node) {
|
|
115
|
-
this.addClassToHast(node, "has-line-numbers");
|
|
116
|
-
if (startLine !== 1) {
|
|
117
|
-
const existingStyle = node.properties?.style || "";
|
|
118
|
-
const newStyle = existingStyle ? `${existingStyle}; --line-start: ${startLine}` : `--line-start: ${startLine}`;
|
|
119
|
-
node.properties = {
|
|
120
|
-
...node.properties,
|
|
121
|
-
style: newStyle
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
line(node) {
|
|
126
|
-
this.addClassToHast(node, "line-numbers");
|
|
127
|
-
return node;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/lib/hook.ts
|
|
133
|
-
var DEFAULT_THEMES = {
|
|
134
|
-
light: "github-light",
|
|
135
|
-
dark: "github-dark"
|
|
136
|
-
};
|
|
137
|
-
var useShikiHighlighter = (code, lang, themeInput, options = {}, highlighterFactory) => {
|
|
138
|
-
const [highlightedCode, setHighlightedCode] = useState(null);
|
|
139
|
-
const [stableLang, langRev] = useStableOptions(lang);
|
|
140
|
-
const [stableTheme, themeRev] = useStableOptions(themeInput);
|
|
141
|
-
const [stableOpts, optsRev] = useStableOptions(options);
|
|
142
|
-
const { languageId, langsToLoad } = useMemo(
|
|
143
|
-
() => resolveLanguage(
|
|
144
|
-
stableLang,
|
|
145
|
-
stableOpts.customLanguages,
|
|
146
|
-
stableOpts.langAlias
|
|
147
|
-
),
|
|
148
|
-
[stableLang, stableOpts.customLanguages, stableOpts.langAlias]
|
|
149
|
-
);
|
|
150
|
-
const { isMultiTheme, themeId, multiTheme, singleTheme, themesToLoad } = useMemo(() => resolveTheme(stableTheme), [stableTheme]);
|
|
151
|
-
const timeoutControl = useRef2({
|
|
152
|
-
nextAllowedTime: 0,
|
|
153
|
-
timeoutId: void 0
|
|
154
|
-
});
|
|
155
|
-
const shikiOptions = useMemo(() => {
|
|
156
|
-
const languageOption = { lang: languageId };
|
|
157
|
-
const {
|
|
158
|
-
defaultColor,
|
|
159
|
-
cssVariablePrefix,
|
|
160
|
-
showLineNumbers,
|
|
161
|
-
startingLineNumber,
|
|
162
|
-
...restOptions
|
|
163
|
-
} = stableOpts;
|
|
164
|
-
const themeOptions = isMultiTheme ? {
|
|
165
|
-
themes: multiTheme || DEFAULT_THEMES,
|
|
166
|
-
defaultColor,
|
|
167
|
-
cssVariablePrefix
|
|
168
|
-
} : {
|
|
169
|
-
theme: singleTheme || DEFAULT_THEMES.dark
|
|
170
|
-
};
|
|
171
|
-
const transformers = restOptions.transformers || [];
|
|
172
|
-
if (showLineNumbers) {
|
|
173
|
-
transformers.push(lineNumbersTransformer(startingLineNumber));
|
|
174
|
-
}
|
|
175
|
-
return {
|
|
176
|
-
...languageOption,
|
|
177
|
-
...themeOptions,
|
|
178
|
-
...restOptions,
|
|
179
|
-
transformers
|
|
180
|
-
};
|
|
181
|
-
}, [languageId, themeId, langRev, themeRev, optsRev]);
|
|
182
|
-
useEffect(() => {
|
|
183
|
-
let isMounted = true;
|
|
184
|
-
const highlightCode = async () => {
|
|
185
|
-
if (!languageId) return;
|
|
186
|
-
const highlighter = stableOpts.highlighter ? stableOpts.highlighter : await highlighterFactory(
|
|
187
|
-
langsToLoad,
|
|
188
|
-
themesToLoad,
|
|
189
|
-
stableOpts.engine
|
|
190
|
-
);
|
|
191
|
-
const loadedLanguages = highlighter.getLoadedLanguages();
|
|
192
|
-
const langToUse = loadedLanguages.includes(languageId) ? languageId : "plaintext";
|
|
193
|
-
const finalOptions = { ...shikiOptions, lang: langToUse };
|
|
194
|
-
if (isMounted) {
|
|
195
|
-
const output = stableOpts.outputFormat === "html" ? highlighter.codeToHtml(code, finalOptions) : toJsxRuntime(highlighter.codeToHast(code, finalOptions), {
|
|
196
|
-
jsx,
|
|
197
|
-
jsxs,
|
|
198
|
-
Fragment
|
|
199
|
-
});
|
|
200
|
-
setHighlightedCode(output);
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
const { delay } = stableOpts;
|
|
204
|
-
if (delay) {
|
|
205
|
-
throttleHighlighting(highlightCode, timeoutControl, delay);
|
|
206
|
-
} else {
|
|
207
|
-
highlightCode().catch(console.error);
|
|
208
|
-
}
|
|
209
|
-
return () => {
|
|
210
|
-
isMounted = false;
|
|
211
|
-
clearTimeout(timeoutControl.current.timeoutId);
|
|
212
|
-
};
|
|
213
|
-
}, [
|
|
214
|
-
code,
|
|
215
|
-
shikiOptions,
|
|
216
|
-
stableOpts.delay,
|
|
217
|
-
stableOpts.highlighter,
|
|
218
|
-
langsToLoad,
|
|
219
|
-
themesToLoad
|
|
220
|
-
]);
|
|
221
|
-
return highlightedCode;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
// src/lib/plugins.ts
|
|
225
|
-
import { visit } from "unist-util-visit";
|
|
226
|
-
function rehypeInlineCodeProperty() {
|
|
227
|
-
return (tree) => {
|
|
228
|
-
visit(tree, "element", (node, _index, parent) => {
|
|
229
|
-
if (node.tagName === "code" && parent.tagName !== "pre") {
|
|
230
|
-
node.properties.inline = true;
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
var isInlineCode = (node) => {
|
|
236
|
-
const textContent = (node.children || []).filter((child) => child.type === "text").map((child) => child.value).join("");
|
|
237
|
-
return !textContent.includes("\n");
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// #style-inject:#style-inject
|
|
241
|
-
function styleInject(css, { insertAt } = {}) {
|
|
242
|
-
if (!css || typeof document === "undefined") return;
|
|
243
|
-
const head = document.head || document.getElementsByTagName("head")[0];
|
|
244
|
-
const style = document.createElement("style");
|
|
245
|
-
style.type = "text/css";
|
|
246
|
-
if (insertAt === "top") {
|
|
247
|
-
if (head.firstChild) {
|
|
248
|
-
head.insertBefore(style, head.firstChild);
|
|
249
|
-
} else {
|
|
250
|
-
head.appendChild(style);
|
|
251
|
-
}
|
|
252
|
-
} else {
|
|
253
|
-
head.appendChild(style);
|
|
254
|
-
}
|
|
255
|
-
if (style.styleSheet) {
|
|
256
|
-
style.styleSheet.cssText = css;
|
|
257
|
-
} else {
|
|
258
|
-
style.appendChild(document.createTextNode(css));
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// src/lib/styles.css
|
|
263
|
-
styleInject(".relative {\n position: relative;\n}\n.defaultStyles pre {\n overflow: auto;\n border-radius: 0.5rem;\n padding-left: 1.5rem;\n padding-right: 1.5rem;\n padding-top: 1.25rem;\n padding-bottom: 1.25rem;\n}\n.languageLabel {\n position: absolute;\n right: 0.75rem;\n top: 0.5rem;\n font-family: monospace;\n font-size: 0.75rem;\n letter-spacing: -0.05em;\n color: rgba(107, 114, 128, 0.85);\n}\n.line-numbers::before {\n counter-increment: line-number;\n content: counter(line-number);\n display: inline-flex;\n justify-content: flex-end;\n align-items: flex-start;\n box-sizing: content-box;\n min-width: var(--line-numbers-width, 2ch);\n padding-left: var(--line-numbers-padding-left, 2ch);\n padding-right: var(--line-numbers-padding-right, 2ch);\n color: var(--line-numbers-foreground, rgba(107, 114, 128, 0.6));\n font-size: var(--line-numbers-font-size, inherit);\n font-weight: var(--line-numbers-font-weight, inherit);\n line-height: var(--line-numbers-line-height, inherit);\n font-family: var(--line-numbers-font-family, inherit);\n opacity: var(--line-numbers-opacity, 1);\n user-select: none;\n pointer-events: none;\n}\n.has-line-numbers {\n counter-reset: line-number calc(var(--line-start, 1) - 1);\n --line-numbers-foreground: rgba(107, 114, 128, 0.5);\n --line-numbers-width: 2ch;\n --line-numbers-padding-left: 0ch;\n --line-numbers-padding-right: 2ch;\n --line-numbers-font-size: inherit;\n --line-numbers-font-weight: inherit;\n --line-numbers-line-height: inherit;\n --line-numbers-font-family: inherit;\n --line-numbers-opacity: 1;\n}\n");
|
|
264
|
-
|
|
265
|
-
// src/lib/component.tsx
|
|
266
|
-
import { clsx } from "clsx";
|
|
267
|
-
import { forwardRef } from "react";
|
|
268
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
269
|
-
var createShikiHighlighterComponent = (useShikiHighlighterImpl) => {
|
|
270
|
-
return forwardRef(
|
|
271
|
-
({
|
|
272
|
-
language,
|
|
273
|
-
theme,
|
|
274
|
-
delay,
|
|
275
|
-
transformers,
|
|
276
|
-
defaultColor,
|
|
277
|
-
cssVariablePrefix,
|
|
278
|
-
addDefaultStyles = true,
|
|
279
|
-
style,
|
|
280
|
-
langStyle,
|
|
281
|
-
className,
|
|
282
|
-
langClassName,
|
|
283
|
-
showLanguage = true,
|
|
284
|
-
showLineNumbers = false,
|
|
285
|
-
startingLineNumber = 1,
|
|
286
|
-
children: code,
|
|
287
|
-
as: Element = "pre",
|
|
288
|
-
customLanguages,
|
|
289
|
-
...shikiOptions
|
|
290
|
-
}, ref) => {
|
|
291
|
-
const options = {
|
|
292
|
-
delay,
|
|
293
|
-
transformers,
|
|
294
|
-
customLanguages,
|
|
295
|
-
showLineNumbers,
|
|
296
|
-
defaultColor,
|
|
297
|
-
cssVariablePrefix,
|
|
298
|
-
startingLineNumber,
|
|
299
|
-
...shikiOptions
|
|
300
|
-
};
|
|
301
|
-
const { displayLanguageId } = resolveLanguage(
|
|
302
|
-
language,
|
|
303
|
-
customLanguages
|
|
304
|
-
);
|
|
305
|
-
const highlightedCode = useShikiHighlighterImpl(
|
|
306
|
-
code,
|
|
307
|
-
language,
|
|
308
|
-
theme,
|
|
309
|
-
options
|
|
310
|
-
);
|
|
311
|
-
const isHtmlOutput = typeof highlightedCode === "string";
|
|
312
|
-
return /* @__PURE__ */ jsxs2(
|
|
313
|
-
Element,
|
|
314
|
-
{
|
|
315
|
-
ref,
|
|
316
|
-
"data-testid": "shiki-container",
|
|
317
|
-
className: clsx(
|
|
318
|
-
"relative",
|
|
319
|
-
"not-prose",
|
|
320
|
-
addDefaultStyles && "defaultStyles",
|
|
321
|
-
className
|
|
322
|
-
),
|
|
323
|
-
style,
|
|
324
|
-
id: "shiki-container",
|
|
325
|
-
children: [
|
|
326
|
-
showLanguage && displayLanguageId ? /* @__PURE__ */ jsx2(
|
|
327
|
-
"span",
|
|
328
|
-
{
|
|
329
|
-
className: clsx("languageLabel", langClassName),
|
|
330
|
-
style: langStyle,
|
|
331
|
-
id: "language-label",
|
|
332
|
-
children: displayLanguageId
|
|
333
|
-
}
|
|
334
|
-
) : null,
|
|
335
|
-
isHtmlOutput ? /* @__PURE__ */ jsx2("div", { dangerouslySetInnerHTML: { __html: highlightedCode } }) : highlightedCode
|
|
336
|
-
]
|
|
337
|
-
}
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
);
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
export {
|
|
344
|
-
useShikiHighlighter,
|
|
345
|
-
rehypeInlineCodeProperty,
|
|
346
|
-
isInlineCode,
|
|
347
|
-
createShikiHighlighterComponent
|
|
348
|
-
};
|
|
349
|
-
//# sourceMappingURL=chunk-EXJNTVNR.js.map
|