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.
package/dist/index.mjs ADDED
@@ -0,0 +1,53 @@
1
+ import { a as isLoadableLanguage, i as useHighlight, n as isInlineCode, r as rehypeInlineCodeProperty, t as createShikiHighlighterComponent } from "./component-C5lsWZSq.mjs";
2
+ import { bundledLanguages, getSingletonHighlighter } from "shiki";
3
+ import { createOnigurumaEngine } from "shiki/engine/oniguruma";
4
+ import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
5
+ //#region src/bundles/full.ts
6
+ /**
7
+ * Creates a highlighter using the full Shiki bundle with all languages and themes.
8
+ * This is the largest bundle but provides maximum compatibility.
9
+ */
10
+ async function createFullHighlighter(langsToLoad, themesToLoad, engine) {
11
+ return await getSingletonHighlighter({
12
+ langs: langsToLoad.filter((lang) => isLoadableLanguage(lang, bundledLanguages)),
13
+ themes: themesToLoad,
14
+ engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
15
+ });
16
+ }
17
+ //#endregion
18
+ //#region src/index.ts
19
+ /**
20
+ * Highlight code with shiki (full bundle)
21
+ *
22
+ * @param code - Code to highlight
23
+ * @param lang - Language (bundled or custom)
24
+ * @param theme - Theme (bundled, multi-theme, or custom)
25
+ * @param options - react-shiki options + shiki options
26
+ * @returns Highlighted code as React elements or HTML string
27
+ *
28
+ * @example
29
+ * ```tsx
30
+ * const highlighted = useShikiHighlighter(
31
+ * 'const x = 1;',
32
+ * 'typescript',
33
+ * {
34
+ * light: 'github-light',
35
+ * dark: 'github-dark'
36
+ * }
37
+ * );
38
+ * ```
39
+ *
40
+ * Full bundle (~6.4MB minified, 1.2MB gzipped). For smaller bundles: `react-shiki/web` or `react-shiki/core`
41
+ */
42
+ const useShikiHighlighter = (code, lang, themeInput, options = {}) => {
43
+ return useHighlight(code, lang, themeInput, options, createFullHighlighter);
44
+ };
45
+ /**
46
+ * ShikiHighlighter component using the full bundle.
47
+ * Includes all languages and themes for maximum compatibility.
48
+ */
49
+ const ShikiHighlighter = createShikiHighlighterComponent(useShikiHighlighter);
50
+ //#endregion
51
+ export { ShikiHighlighter, ShikiHighlighter as default, createJavaScriptRawEngine, createJavaScriptRegexEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
52
+
53
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"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 { 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 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 useHighlight(\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":";;;;;;;;;AAeA,eAAsB,sBACpB,aACA,cACA,QACsB;AAKtB,QAAO,MAAM,wBAAwB;EACnC,OALY,YAAY,QAAQ,SAChC,mBAAmB,MAAM,iBAAiB,CAIrC;EACL,QAAQ;EACR,QAAQ,UAAU,sBAAsB,OAAO,cAAc;EAC9D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACwBJ,MAAa,uBACX,MACA,MACA,YACA,UAAU,EAAE,KACT;AACH,QAAO,aACL,MACA,MACA,YACA,SACA,sBACD;;;;;;AAOH,MAAa,mBAAmB,gCAC9B,oBACD"}
package/dist/style.css ADDED
@@ -0,0 +1,55 @@
1
+ @layer base {
2
+ .rs-root {
3
+ position: relative;
4
+ }
5
+
6
+ .rs-default-styles pre {
7
+ border-radius: .5rem;
8
+ padding: 1.25rem 1.5rem;
9
+ overflow: auto;
10
+ }
11
+
12
+ .rs-language-label {
13
+ letter-spacing: -.05em;
14
+ color: #6b7280d9;
15
+ font-family: monospace;
16
+ font-size: .75rem;
17
+ position: absolute;
18
+ top: .5rem;
19
+ right: .75rem;
20
+ }
21
+ }
22
+ @layer base {
23
+ .line-numbers:before, .rs-line-number:before {
24
+ counter-increment: line-number;
25
+ content: counter(line-number);
26
+ box-sizing: content-box;
27
+ min-width: var(--rs-line-numbers-width, 2ch);
28
+ padding-left: var(--rs-line-numbers-padding-left, 2ch);
29
+ padding-right: var(--rs-line-numbers-padding-right, 2ch);
30
+ color: var(--rs-line-numbers-foreground, #6b728099);
31
+ font-size: var(--rs-line-numbers-font-size, inherit);
32
+ font-weight: var(--rs-line-numbers-font-weight, inherit);
33
+ line-height: var(--rs-line-numbers-line-height, inherit);
34
+ font-family: var(--rs-line-numbers-font-family, inherit);
35
+ opacity: var(--rs-line-numbers-opacity, 1);
36
+ user-select: none;
37
+ pointer-events: none;
38
+ justify-content: flex-end;
39
+ align-items: flex-start;
40
+ display: inline-flex;
41
+ }
42
+
43
+ .has-line-numbers, .rs-has-line-numbers {
44
+ counter-reset: line-number calc(var(--line-start, 1) - 1);
45
+ --rs-line-numbers-foreground: var(--line-numbers-foreground, #6b728080);
46
+ --rs-line-numbers-width: var(--line-numbers-width, 2ch);
47
+ --rs-line-numbers-padding-left: var(--line-numbers-padding-left, 0ch);
48
+ --rs-line-numbers-padding-right: var(--line-numbers-padding-right, 2ch);
49
+ --rs-line-numbers-font-size: var(--line-numbers-font-size, inherit);
50
+ --rs-line-numbers-font-weight: var(--line-numbers-font-weight, inherit);
51
+ --rs-line-numbers-line-height: var(--line-numbers-line-height, inherit);
52
+ --rs-line-numbers-font-family: var(--line-numbers-font-family, inherit);
53
+ --rs-line-numbers-opacity: var(--line-numbers-opacity, 1);
54
+ }
55
+ }
package/dist/web.d.mts ADDED
@@ -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 { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
4
+ import { LanguageRegistration } from "shiki/bundle/web";
5
+
6
+ //#region src/web.d.ts
7
+ /**
8
+ * Highlight code with shiki (web 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
+ * Web bundle (~3.8MB minified, 695KB gzipped). For other bundles: `react-shiki` or `react-shiki/core`
29
+ */
30
+ declare const useShikiHighlighter: UseShikiHighlighter;
31
+ /**
32
+ * ShikiHighlighter component using the web bundle.
33
+ * Includes web-focused languages for balanced size and functionality.
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=web.d.mts.map
package/dist/web.mjs ADDED
@@ -0,0 +1,54 @@
1
+ import { a as isLoadableLanguage, i as useHighlight, n as isInlineCode, r as rehypeInlineCodeProperty, t as createShikiHighlighterComponent } from "./component-C5lsWZSq.mjs";
2
+ import { createOnigurumaEngine } from "shiki/engine/oniguruma";
3
+ import { createJavaScriptRawEngine, createJavaScriptRegexEngine } from "shiki/engine/javascript";
4
+ import { bundledLanguages, getSingletonHighlighter } from "shiki/bundle/web";
5
+ //#region src/bundles/web.ts
6
+ /**
7
+ * Creates a highlighter using the web Shiki bundle with web-focused languages.
8
+ * Smaller than the full bundle while covering most web development needs.
9
+ * Includes: HTML, CSS, JS, TS, JSON, Markdown, Vue, JSX, Svelte, etc.
10
+ */
11
+ async function createWebHighlighter(langsToLoad, themesToLoad, engine) {
12
+ return await getSingletonHighlighter({
13
+ langs: langsToLoad.filter((lang) => isLoadableLanguage(lang, bundledLanguages)),
14
+ themes: themesToLoad,
15
+ engine: engine ?? createOnigurumaEngine(import("shiki/wasm"))
16
+ });
17
+ }
18
+ //#endregion
19
+ //#region src/web.ts
20
+ /**
21
+ * Highlight code with shiki (web bundle)
22
+ *
23
+ * @param code - Code to highlight
24
+ * @param lang - Language (bundled or custom)
25
+ * @param theme - Theme (bundled, multi-theme, or custom)
26
+ * @param options - react-shiki options + shiki options
27
+ * @returns Highlighted code as React elements or HTML string
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * const highlighted = useShikiHighlighter(
32
+ * 'const x = 1;',
33
+ * 'typescript',
34
+ * {
35
+ * light: 'github-light',
36
+ * dark: 'github-dark'
37
+ * }
38
+ * );
39
+ * ```
40
+ *
41
+ * Web bundle (~3.8MB minified, 695KB gzipped). For other bundles: `react-shiki` or `react-shiki/core`
42
+ */
43
+ const useShikiHighlighter = (code, lang, themeInput, options = {}) => {
44
+ return useHighlight(code, lang, themeInput, options, createWebHighlighter);
45
+ };
46
+ /**
47
+ * ShikiHighlighter component using the web bundle.
48
+ * Includes web-focused languages for balanced size and functionality.
49
+ */
50
+ const ShikiHighlighter = createShikiHighlighterComponent(useShikiHighlighter);
51
+ //#endregion
52
+ export { ShikiHighlighter, ShikiHighlighter as default, createJavaScriptRawEngine, createJavaScriptRegexEngine, isInlineCode, rehypeInlineCodeProperty, useShikiHighlighter };
53
+
54
+ //# sourceMappingURL=web.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.mjs","names":[],"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 { 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 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 useHighlight(\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":";;;;;;;;;;AAgBA,eAAsB,qBACpB,aACA,cACA,QACsB;AAKtB,QAAO,MAAM,wBAAwB;EACnC,OALY,YAAY,QAAQ,SAChC,mBAAmB,MAAM,iBAAiB,CAIrC;EACL,QAAQ;EACR,QAAQ,UAAU,sBAAsB,OAAO,cAAc;EAC9D,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACuBJ,MAAa,uBACX,MACA,MACA,YACA,UAAU,EAAE,KACT;AACH,QAAO,aACL,MACA,MACA,YACA,SACA,qBACD;;;;;;AAOH,MAAa,mBAAmB,gCAC9B,oBACD"}
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.3",
4
+ "version": "0.10.0",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Bassim Shahidy",
@@ -11,7 +11,7 @@
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "directory": "package",
14
- "url": "https://github.com/AVGVSTVS96/react-shiki"
14
+ "url": "git+https://github.com/AVGVSTVS96/react-shiki.git"
15
15
  },
16
16
  "homepage": "https://react-shiki.vercel.app/",
17
17
  "keywords": [
@@ -24,8 +24,8 @@
24
24
  "react-syntax-highlighter"
25
25
  ],
26
26
  "type": "module",
27
- "main": "./dist/index.js",
28
- "types": "./dist/index.d.ts",
27
+ "main": "./dist/index.mjs",
28
+ "types": "./dist/index.d.mts",
29
29
  "files": [
30
30
  "dist",
31
31
  "src/styles/features.css",
@@ -41,16 +41,16 @@
41
41
  },
42
42
  "exports": {
43
43
  ".": {
44
- "types": "./dist/index.d.ts",
45
- "default": "./dist/index.js"
44
+ "types": "./dist/index.d.mts",
45
+ "default": "./dist/index.mjs"
46
46
  },
47
47
  "./web": {
48
- "types": "./dist/web.d.ts",
49
- "default": "./dist/web.js"
48
+ "types": "./dist/web.d.mts",
49
+ "default": "./dist/web.mjs"
50
50
  },
51
51
  "./core": {
52
- "types": "./dist/core.d.ts",
53
- "default": "./dist/core.js"
52
+ "types": "./dist/core.d.mts",
53
+ "default": "./dist/core.mjs"
54
54
  },
55
55
  "./css": {
56
56
  "types": "./src/styles/css.d.ts",
@@ -58,10 +58,10 @@
58
58
  }
59
59
  },
60
60
  "peerDependencies": {
61
- "@types/react": ">=16.8.0",
62
- "@types/react-dom": ">=16.8.0",
63
- "react": ">= 16.8.0",
64
- "react-dom": ">= 16.8.0"
61
+ "@types/react": ">=16.14.0",
62
+ "@types/react-dom": ">=16.14.0",
63
+ "react": ">=16.14.0",
64
+ "react-dom": ">=16.14.0"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@types/react": {
@@ -75,25 +75,28 @@
75
75
  "clsx": "^2.1.1",
76
76
  "dequal": "^2.0.3",
77
77
  "hast-util-to-jsx-runtime": "^2.3.6",
78
- "shiki": "^4.0.0",
78
+ "shiki": "^4.0.2",
79
79
  "unist-util-visit": "^5.1.0"
80
80
  },
81
81
  "devDependencies": {
82
+ "@arethetypeswrong/core": "^0.18.2",
82
83
  "@testing-library/jest-dom": "^6.9.1",
83
84
  "@testing-library/react": "^16.3.2",
85
+ "@tsdown/css": "0.21.10",
84
86
  "@types/hast": "^3.0.4",
85
87
  "@types/jest": "^30.0.0",
86
- "@types/node": "25.3.3",
87
- "@types/react": "^19.1.10",
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
+ "@types/node": "25.6.0",
89
+ "@types/react": "^19.2.14",
90
+ "@vitejs/plugin-react": "^6.0.1",
91
+ "html-react-parser": "^6.1.0",
92
+ "jsdom": "^29.1.1",
93
+ "publint": "^0.3.19",
94
+ "tsdown": "^0.21.10",
95
+ "vitest": "^4.1.5"
93
96
  },
94
97
  "scripts": {
95
- "dev": "tsup --watch",
96
- "build": "tsup",
98
+ "dev": "tsdown --watch",
99
+ "build": "tsdown",
97
100
  "test": "vitest",
98
101
  "bench": "vitest bench",
99
102
  "lint": "biome lint .",
@@ -1 +1 @@
1
- export {};
1
+ declare module '*.css';
@@ -23,14 +23,29 @@
23
23
  .has-line-numbers,
24
24
  .rs-has-line-numbers {
25
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));
26
+ --rs-line-numbers-foreground: var(
27
+ --line-numbers-foreground,
28
+ rgba(107, 114, 128, 0.5)
29
+ );
27
30
  --rs-line-numbers-width: var(--line-numbers-width, 2ch);
28
31
  --rs-line-numbers-padding-left: var(--line-numbers-padding-left, 0ch);
29
- --rs-line-numbers-padding-right: var(--line-numbers-padding-right, 2ch);
32
+ --rs-line-numbers-padding-right: var(
33
+ --line-numbers-padding-right,
34
+ 2ch
35
+ );
30
36
  --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);
37
+ --rs-line-numbers-font-weight: var(
38
+ --line-numbers-font-weight,
39
+ inherit
40
+ );
41
+ --rs-line-numbers-line-height: var(
42
+ --line-numbers-line-height,
43
+ inherit
44
+ );
45
+ --rs-line-numbers-font-family: var(
46
+ --line-numbers-font-family,
47
+ inherit
48
+ );
34
49
  --rs-line-numbers-opacity: var(--line-numbers-opacity, 1);
35
50
  }
36
51
  }