rn-shiki 0.0.37-3 → 0.0.37-32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. package/lib/commonjs/components/syntax/SyntaxHighlighter.js +100 -60
  2. package/lib/commonjs/components/syntax/SyntaxHighlighter.js.map +1 -1
  3. package/lib/commonjs/hooks/useSyntaxHighlighter.js +18 -10
  4. package/lib/commonjs/hooks/useSyntaxHighlighter.js.map +1 -1
  5. package/lib/commonjs/index.js +0 -23
  6. package/lib/commonjs/index.js.map +1 -1
  7. package/lib/commonjs/syntax/{highlighter/index.js → highlighter.js} +20 -10
  8. package/lib/commonjs/syntax/highlighter.js.map +1 -0
  9. package/lib/commonjs/utils/style-transformer.js +103 -0
  10. package/lib/commonjs/utils/style-transformer.js.map +1 -0
  11. package/lib/module/components/syntax/SyntaxHighlighter.js +100 -61
  12. package/lib/module/components/syntax/SyntaxHighlighter.js.map +1 -1
  13. package/lib/module/hooks/useSyntaxHighlighter.js +17 -9
  14. package/lib/module/hooks/useSyntaxHighlighter.js.map +1 -1
  15. package/lib/module/index.js +1 -3
  16. package/lib/module/index.js.map +1 -1
  17. package/lib/module/syntax/highlighter.js +44 -0
  18. package/lib/module/syntax/highlighter.js.map +1 -0
  19. package/lib/module/utils/style-transformer.js +98 -0
  20. package/lib/module/utils/style-transformer.js.map +1 -0
  21. package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts +2 -10
  22. package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts.map +1 -1
  23. package/lib/typescript/hooks/useSyntaxHighlighter.d.ts +3 -2
  24. package/lib/typescript/hooks/useSyntaxHighlighter.d.ts.map +1 -1
  25. package/lib/typescript/index.d.ts +1 -3
  26. package/lib/typescript/index.d.ts.map +1 -1
  27. package/lib/typescript/syntax/{highlighter/index.d.ts → highlighter.d.ts} +3 -4
  28. package/lib/typescript/syntax/highlighter.d.ts.map +1 -0
  29. package/lib/typescript/types/shiki.d.ts +10 -8
  30. package/lib/typescript/types/shiki.d.ts.map +1 -1
  31. package/lib/typescript/utils/string.d.ts +1 -1
  32. package/lib/typescript/utils/string.d.ts.map +1 -1
  33. package/lib/typescript/utils/style-transformer.d.ts +9 -0
  34. package/lib/typescript/utils/style-transformer.d.ts.map +1 -0
  35. package/package.json +2 -6
  36. package/src/components/syntax/SyntaxHighlighter.tsx +85 -33
  37. package/src/hooks/useSyntaxHighlighter.ts +13 -4
  38. package/src/index.ts +1 -4
  39. package/src/syntax/{highlighter/index.ts → highlighter.ts} +22 -10
  40. package/src/types/shiki.ts +7 -8
  41. package/src/utils/string.ts +1 -1
  42. package/src/utils/style-transformer.ts +50 -94
  43. package/lib/commonjs/components/syntax/SyntaxLine.js +0 -36
  44. package/lib/commonjs/components/syntax/SyntaxLine.js.map +0 -1
  45. package/lib/commonjs/components/syntax/index.js +0 -21
  46. package/lib/commonjs/components/syntax/index.js.map +0 -1
  47. package/lib/commonjs/syntax/highlighter/index.js.map +0 -1
  48. package/lib/commonjs/syntax/index.js +0 -19
  49. package/lib/commonjs/syntax/index.js.map +0 -1
  50. package/lib/commonjs/types/index.js +0 -2
  51. package/lib/commonjs/types/index.js.map +0 -1
  52. package/lib/commonjs/types/shiki.d.js +0 -6
  53. package/lib/commonjs/types/shiki.d.js.map +0 -1
  54. package/lib/commonjs/utils/index.js +0 -17
  55. package/lib/commonjs/utils/index.js.map +0 -1
  56. package/lib/module/components/syntax/SyntaxLine.js +0 -31
  57. package/lib/module/components/syntax/SyntaxLine.js.map +0 -1
  58. package/lib/module/components/syntax/index.js +0 -5
  59. package/lib/module/components/syntax/index.js.map +0 -1
  60. package/lib/module/syntax/highlighter/index.js +0 -34
  61. package/lib/module/syntax/highlighter/index.js.map +0 -1
  62. package/lib/module/syntax/index.js +0 -4
  63. package/lib/module/syntax/index.js.map +0 -1
  64. package/lib/module/types/index.js +0 -2
  65. package/lib/module/types/index.js.map +0 -1
  66. package/lib/module/types/shiki.d.js +0 -4
  67. package/lib/module/types/shiki.d.js.map +0 -1
  68. package/lib/module/utils/index.js +0 -4
  69. package/lib/module/utils/index.js.map +0 -1
  70. package/lib/typescript/components/syntax/SyntaxLine.d.ts +0 -9
  71. package/lib/typescript/components/syntax/SyntaxLine.d.ts.map +0 -1
  72. package/lib/typescript/components/syntax/index.d.ts +0 -3
  73. package/lib/typescript/components/syntax/index.d.ts.map +0 -1
  74. package/lib/typescript/syntax/highlighter/index.d.ts.map +0 -1
  75. package/lib/typescript/syntax/index.d.ts +0 -2
  76. package/lib/typescript/syntax/index.d.ts.map +0 -1
  77. package/lib/typescript/types/index.d.ts +0 -7
  78. package/lib/typescript/types/index.d.ts.map +0 -1
  79. package/lib/typescript/utils/index.d.ts +0 -2
  80. package/lib/typescript/utils/index.d.ts.map +0 -1
  81. package/src/components/syntax/SyntaxLine.tsx +0 -81
  82. package/src/components/syntax/index.ts +0 -2
  83. package/src/syntax/index.ts +0 -1
  84. package/src/types/index.ts +0 -6
  85. package/src/utils/index.ts +0 -1
@@ -1,7 +1,10 @@
1
- import React from 'react'
2
- import { Platform, ScrollView, type ScrollViewProps, StyleSheet, Text, type TextStyle, View } from 'react-native'
1
+ import type { ColorValue, StyleProp, TextStyle } from 'react-native'
2
+ import type { ThemedToken, ThemeInput, ThemeRegistration } from 'shiki'
3
+ import type { SyntaxHighlighterProps } from 'src/types/shiki'
4
+ import React, { useMemo } from 'react'
5
+ import { Platform, ScrollView, StyleSheet, Text, View } from 'react-native'
3
6
  import { useSyntaxHighlighter } from '../../hooks/useSyntaxHighlighter'
4
- import { convertShikiTheme } from '../../utils/style-transformer'
7
+ import { getRNStylesFromShikiStyle } from '../../utils/style-transformer'
5
8
 
6
9
  const monospaceFont = Platform.select({
7
10
  ios: 'Menlo',
@@ -9,31 +12,81 @@ const monospaceFont = Platform.select({
9
12
  default: 'monospace',
10
13
  })
11
14
 
12
- interface SyntaxHighlighterProps {
13
- text: string
14
- language: any
15
- languageId: string
16
- theme: any
17
- textStyle?: TextStyle
18
- scrollViewProps?: ScrollViewProps
15
+ interface TokenStyle extends Omit<TextStyle, 'color' | 'fontWeight'> {
16
+ color?: ColorValue
17
+ fontStyle?: 'normal' | 'italic'
18
+ fontWeight?: FontWeight
19
+ fontFamily?: string
19
20
  }
20
21
 
21
- const styles = StyleSheet.create({
22
+ type FontWeight = 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900'
23
+
24
+ function getThemeRegistration(theme: ThemeInput): ThemeRegistration {
25
+ if ('default' in theme) {
26
+ return theme.default
27
+ }
28
+ return theme as ThemeRegistration
29
+ }
30
+
31
+ const baseStyles = StyleSheet.create({
22
32
  scrollView: {
23
33
  flex: 1,
24
34
  minHeight: 20,
35
+ backgroundColor: '#1e1e1e',
25
36
  },
26
37
  contentContainer: {
27
38
  flexGrow: 1,
39
+ minWidth: '100%',
40
+ },
41
+ codeContainer: {
42
+ paddingVertical: 8,
43
+ minWidth: '100%',
28
44
  },
29
45
  lineContainer: {
46
+ flexDirection: 'row',
47
+ minWidth: '100%',
48
+ paddingHorizontal: 16,
49
+ paddingVertical: 1,
50
+ },
51
+ line: {
30
52
  flexDirection: 'row',
31
53
  flexWrap: 'wrap',
54
+ flex: 1,
55
+ },
56
+ token: {
57
+ fontFamily: monospaceFont,
58
+ fontSize: 14,
59
+ color: '#d4d4d4',
32
60
  },
33
61
  })
34
62
 
35
- const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ text, language, languageId, theme, textStyle, scrollViewProps }) => {
36
- const themeStyles = React.useMemo(() => convertShikiTheme(theme), [theme])
63
+ const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ text, language, languageId, theme, fontSize = 14, showLineNumbers = false }) => {
64
+ const stylesheet = useMemo(() => {
65
+ const themeRegistration = getThemeRegistration(theme)
66
+ const styles = getRNStylesFromShikiStyle(themeRegistration)
67
+
68
+ return StyleSheet.create({
69
+ ...styles,
70
+ editor: {
71
+ backgroundColor: themeRegistration.colors?.['editor.background'] || '#1e1e1e',
72
+ },
73
+ token: {
74
+ ...baseStyles.token,
75
+ fontSize,
76
+ color: themeRegistration.colors?.['editor.foreground'] || '#d4d4d4',
77
+ },
78
+ lineNumber: {
79
+ width: 40,
80
+ paddingRight: 16,
81
+ textAlign: 'right',
82
+ color: themeRegistration.colors?.['editorLineNumber.foreground'] || '#858585',
83
+ fontFamily: monospaceFont,
84
+ fontSize,
85
+ opacity: 0.5,
86
+ },
87
+ })
88
+ }, [theme, fontSize])
89
+
37
90
  const { tokens } = useSyntaxHighlighter({
38
91
  text,
39
92
  language,
@@ -41,38 +94,37 @@ const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ text, language, l
41
94
  theme,
42
95
  })
43
96
 
44
- const renderToken = (token: any, index: number, lineIndex: number) => {
45
- const tokenStyle: TextStyle = {
46
- ...themeStyles.token,
47
- fontFamily: monospaceFont,
48
- ...(token.color && { color: token.color }),
49
- ...(token.fontStyle === 'italic' && themeStyles.italic),
50
- ...(token.fontWeight === 'bold' && themeStyles.bold),
51
- ...textStyle,
97
+ const renderToken = (token: ThemedToken, index: number) => {
98
+ const styles: StyleProp<TokenStyle>[] = [stylesheet.token]
99
+
100
+ if (token.color) {
101
+ styles.push({ color: token.color })
102
+ }
103
+
104
+ if (token.fontStyle) {
105
+ styles.push({
106
+ fontStyle: token.fontStyle as unknown as 'normal' | 'italic',
107
+ fontWeight: (token.fontStyle as unknown as string).includes('bold') ? 'bold' : 'normal',
108
+ })
52
109
  }
53
110
 
54
111
  return (
55
- <Text key={`${lineIndex}-${index}`} style={tokenStyle}>
112
+ <Text key={index} style={styles}>
56
113
  {token.content.replace(/ /g, '\u00A0')}
57
114
  </Text>
58
115
  )
59
116
  }
60
117
 
61
- const renderLine = (line: any[], lineIndex: number) => (
62
- <View key={lineIndex} style={styles.lineContainer}>
63
- {line.map((token, tokenIndex) => renderToken(token, tokenIndex, lineIndex))}
118
+ const renderLine = (line: ThemedToken[], lineIndex: number) => (
119
+ <View key={lineIndex} style={baseStyles.lineContainer}>
120
+ {showLineNumbers && <Text style={stylesheet.lineNumber}>{(lineIndex + 1).toString()}</Text>}
121
+ <View style={baseStyles.line}>{line.map((token, tokenIndex) => renderToken(token, tokenIndex))}</View>
64
122
  </View>
65
123
  )
66
124
 
67
125
  return (
68
- <ScrollView
69
- horizontal
70
- showsHorizontalScrollIndicator={Platform.OS !== 'web'}
71
- style={styles.scrollView}
72
- contentContainerStyle={[styles.contentContainer, themeStyles.container, scrollViewProps?.contentContainerStyle]}
73
- {...scrollViewProps}
74
- >
75
- <View onStartShouldSetResponder={() => true}>{tokens.map((line, index) => renderLine(line, index))}</View>
126
+ <ScrollView horizontal showsHorizontalScrollIndicator={Platform.OS !== 'web'} style={[baseStyles.scrollView, stylesheet.editor]} contentContainerStyle={baseStyles.contentContainer}>
127
+ <View style={baseStyles.codeContainer}>{tokens.map((line, index) => renderLine(line, index))}</View>
76
128
  </ScrollView>
77
129
  )
78
130
  }
@@ -1,6 +1,7 @@
1
- import type { SyntaxHighlighterProps, ThemedToken, TokensResult } from '../types/shiki'
1
+ import type { ThemedToken } from 'shiki'
2
+ import type { SyntaxHighlighterProps, TokensResult } from '../types/shiki'
2
3
  import { useEffect, useState } from 'react'
3
- import { createHighlighter } from '../syntax'
4
+ import { createHighlighter } from '../syntax/highlighter'
4
5
 
5
6
  export function useSyntaxHighlighter({ text, language, languageId, theme }: SyntaxHighlighterProps) {
6
7
  const [tokens, setTokens] = useState<ThemedToken[][]>([])
@@ -19,14 +20,22 @@ export function useSyntaxHighlighter({ text, language, languageId, theme }: Synt
19
20
  }
20
21
 
21
22
  try {
23
+ // First create the highlighter
22
24
  const highlighter = await createHighlighter({
23
25
  langs: [language],
24
- themes: theme ? [theme] : [],
26
+ themes: [theme],
25
27
  })
26
28
 
29
+ // Get resolved theme name
30
+ const themeResolved = highlighter.getLoadedThemes()?.[0]
31
+ if (!themeResolved) {
32
+ throw new Error('Failed to resolve theme')
33
+ }
34
+
35
+ // Use resolved theme for tokenization
27
36
  const result = highlighter.codeToTokens(text, {
28
37
  lang: languageId,
29
- theme: theme || 'none',
38
+ theme: themeResolved,
30
39
  }) as TokensResult
31
40
 
32
41
  if (mounted && result.tokens) {
package/src/index.ts CHANGED
@@ -1,6 +1,3 @@
1
1
  import SyntaxHighlighter from './components/syntax/SyntaxHighlighter'
2
- import SyntaxLine from './components/syntax/SyntaxLine'
3
2
 
4
- export * from './types/shiki'
5
-
6
- export { SyntaxHighlighter, SyntaxLine }
3
+ export { SyntaxHighlighter }
@@ -1,19 +1,31 @@
1
1
  import type { LanguageInput, ThemedToken, ThemeInput } from 'shiki'
2
- import type { TokenType } from '../../types'
2
+ import type { TokenType } from '../types/shiki'
3
3
  import { createHighlighterCore } from 'shiki/dist/core.mjs'
4
4
  import { createJavaScriptRegexEngine } from 'shiki/dist/engine-javascript.mjs'
5
5
 
6
- async function initializeHighlighter(langs: LanguageInput[], themes: ThemeInput[]): Promise<Awaited<ReturnType<typeof createHighlighterCore>>> {
7
- return createHighlighterCore({
8
- engine: createJavaScriptRegexEngine(),
9
- langs,
10
- themes,
11
- })
6
+ const engine = createJavaScriptRegexEngine({
7
+ forgiving: true,
8
+ simulation: true,
9
+ cache: new Map(),
10
+ })
11
+
12
+ async function initializeHighlighter(langs: LanguageInput[], themes: ThemeInput[]) {
13
+ try {
14
+ return await createHighlighterCore({
15
+ langs,
16
+ themes,
17
+ engine, // Pass the configured engine
18
+ })
19
+ }
20
+ catch (err) {
21
+ console.error('Error initializing highlighter:', err)
22
+ throw err
23
+ }
12
24
  }
13
25
 
14
- export async function createHighlighter({ langs, themes }: { langs: LanguageInput[], themes: ThemeInput[] }): Promise<Awaited<ReturnType<typeof createHighlighterCore>>> {
15
- if (!langs?.length || !themes?.length) {
16
- throw new Error('Please provide both `langs` and `themes` when creating a highlighter.')
26
+ export async function createHighlighter({ langs, themes }: { langs: LanguageInput[], themes: ThemeInput[] }) {
27
+ if (!langs?.length) {
28
+ throw new Error('Please provide languages when creating a highlighter.')
17
29
  }
18
30
 
19
31
  try {
@@ -1,20 +1,19 @@
1
- import type { LanguageInput, ThemeRegistrationAny } from 'shiki'
1
+ import type { LanguageInput, ThemedToken, ThemeInput } from 'shiki'
2
2
 
3
- export interface ThemedToken {
3
+ export interface TokenType {
4
4
  content: string
5
5
  color?: string
6
6
  fontStyle?: string
7
- fontWeight?: string
8
- }
9
-
10
- export interface TokensResult {
11
- tokens: ThemedToken[][]
12
7
  }
13
8
 
14
9
  export interface SyntaxHighlighterProps {
15
10
  text: string
16
11
  language: LanguageInput
17
12
  languageId: string
18
- theme?: ThemeRegistrationAny
13
+ theme: ThemeInput
19
14
  fontSize?: number
20
15
  }
16
+
17
+ export interface TokensResult {
18
+ tokens: ThemedToken[][]
19
+ }
@@ -1,4 +1,4 @@
1
- import type { TokenType } from '../types'
1
+ import type { TokenType } from '../types/shiki'
2
2
 
3
3
  export function createContentPreview(tokens: TokenType[], maxLength: number = 20): string {
4
4
  return tokens
@@ -1,108 +1,64 @@
1
- import type { RawThemeSetting, ThemeRegistrationAny } from 'shiki'
2
- import { StyleSheet, type TextStyle } from 'react-native'
1
+ import type { TextStyle } from 'react-native'
2
+ import type { ThemeRegistration } from 'shiki'
3
3
 
4
4
  export interface HighlighterStyleSheet {
5
- container: TextStyle
6
- token: TextStyle
7
- selection: TextStyle
8
- styles: Record<string, TextStyle>
9
- [key: string]: TextStyle | Record<string, TextStyle>
5
+ [key: string]: TextStyle
10
6
  }
11
7
 
12
- interface TokenStyle {
13
- color?: string
14
- fontStyle?: 'normal' | 'italic'
15
- fontWeight?: 'normal' | 'bold'
16
- }
17
-
18
- function processSettings(settings: RawThemeSetting[]): Record<string, TokenStyle> {
19
- const tokenStyles: Record<string, TokenStyle> = {}
20
-
21
- settings.forEach((setting) => {
22
- if (!setting.scope || !setting.settings)
23
- return
8
+ export type ReactStyle = Record<string, TextStyle>
24
9
 
25
- const style: TokenStyle = {}
26
- const { foreground, fontStyle } = setting.settings
27
-
28
- if (foreground) {
29
- style.color = foreground
30
- }
10
+ function normalizeColor(color: string | undefined): string {
11
+ if (!color)
12
+ return 'transparent'
13
+ return color
14
+ }
31
15
 
32
- if (fontStyle) {
33
- if (fontStyle.includes('italic')) {
34
- style.fontStyle = 'italic'
35
- }
36
- if (fontStyle.includes('bold')) {
37
- style.fontWeight = 'bold'
38
- }
16
+ export function getRNStylesFromShikiStyle(theme: ThemeRegistration): HighlighterStyleSheet {
17
+ if (!theme)
18
+ return {}
19
+
20
+ try {
21
+ const styles: HighlighterStyleSheet = {
22
+ editor: {
23
+ backgroundColor: normalizeColor(theme.colors?.['editor.background']),
24
+ },
25
+ base: {
26
+ color: normalizeColor(theme.colors?.['editor.foreground']),
27
+ },
39
28
  }
40
29
 
41
- // Handle single scope
42
- if (typeof setting.scope === 'string') {
43
- tokenStyles[setting.scope] = style
44
- }
45
- // Handle multiple scopes
46
- else if (Array.isArray(setting.scope)) {
47
- setting.scope.forEach((scope) => {
48
- tokenStyles[scope] = style
30
+ if (theme.tokenColors) {
31
+ theme.tokenColors.forEach((token) => {
32
+ if (!token.settings)
33
+ return
34
+
35
+ const style: TextStyle = {}
36
+ if (token.settings.foreground) {
37
+ style.color = token.settings.foreground
38
+ }
39
+ if (token.settings.background) {
40
+ style.backgroundColor = token.settings.background
41
+ }
42
+ if (token.settings.fontStyle) {
43
+ style.fontStyle = token.settings.fontStyle.includes('italic') ? 'italic' : 'normal'
44
+ style.fontWeight = token.settings.fontStyle.includes('bold') ? 'bold' : 'normal'
45
+ }
46
+
47
+ const scopes = Array.isArray(token.scope) ? token.scope : [token.scope]
48
+ scopes.forEach((scope) => {
49
+ if (scope) {
50
+ styles[scope] = style
51
+ }
52
+ })
49
53
  })
50
54
  }
51
- })
52
-
53
- return tokenStyles
54
- }
55
-
56
- export function convertShikiTheme(theme: ThemeRegistrationAny): ReturnType<typeof StyleSheet.create> {
57
- // Get all styles from both settings and tokenColors
58
- const settings = [...(theme.settings || []), ...(theme.tokenColors || [])]
59
55
 
60
- // Process basic colors from the theme
61
- const backgroundColor = theme.colors?.['editor.background'] || theme.bg || '#1e1e1e'
62
- const defaultColor = theme.colors?.['editor.foreground'] || theme.fg || '#d4d4d4'
63
- const selectionColor = theme.colors?.['editor.selectionBackground'] || 'rgba(255, 255, 255, 0.1)'
64
-
65
- // Process token styles
66
- const tokenStyles = processSettings(settings)
67
-
68
- // Convert token styles to RN styles
69
- const tokenStylesMap = Object.entries(tokenStyles).reduce<Record<string, TextStyle>>((acc, [scope, style]) => {
70
- acc[`token-${scope.replace(/\./g, '-')}`] = {
71
- color: style.color,
72
- ...(style.fontStyle && { fontStyle: style.fontStyle }),
73
- ...(style.fontWeight && { fontWeight: style.fontWeight }),
74
- }
75
- return acc
76
- }, {})
77
-
78
- // Create the complete styles object
79
- const completeStyles: HighlighterStyleSheet = {
80
- container: {
81
- backgroundColor,
82
- flex: 1,
83
- padding: 16,
84
- },
85
- token: {
86
- color: defaultColor,
87
- fontSize: 14,
88
- lineHeight: 21,
89
- },
90
- selection: {
91
- backgroundColor: selectionColor,
92
- },
93
- styles: tokenStylesMap,
56
+ return styles
94
57
  }
95
-
96
- return StyleSheet.create(completeStyles)
97
- }
98
-
99
- export function getTokenStyle(theme: HighlighterStyleSheet, tokenTypes: string[], defaultColor: string): TextStyle {
100
- const matchingStyles = tokenTypes.map(type => theme.styles[`token-${type.replace(/\./g, '-')}`]).filter(Boolean)
101
-
102
- return {
103
- ...theme.token,
104
- color: matchingStyles[0]?.color || defaultColor,
105
- ...(matchingStyles.some(s => s?.fontStyle === 'italic') && { fontStyle: 'italic' }),
106
- ...(matchingStyles.some(s => s?.fontWeight === 'bold') && { fontWeight: 'bold' }),
58
+ catch {
59
+ return {
60
+ editor: { backgroundColor: '#1e1e1e' },
61
+ base: { color: '#d4d4d4' },
62
+ }
107
63
  }
108
64
  }
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _reactNative = require("react-native");
9
- var _jsxRuntime = require("react/jsx-runtime");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- function SyntaxLine({
12
- line,
13
- fontSize
14
- }) {
15
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
16
- style: {
17
- flexDirection: 'row',
18
- flexWrap: 'wrap'
19
- },
20
- children: line.map((token, tokenIndex) => {
21
- // Preserve whitespace
22
- const content = token.content.replace(/ /g, '\u00A0');
23
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
24
- style: {
25
- color: token.color,
26
- fontFamily: 'monospace',
27
- fontSize,
28
- fontStyle: token.fontStyle
29
- },
30
- children: content
31
- }, `${content}-${tokenIndex}`);
32
- })
33
- });
34
- }
35
- var _default = exports.default = SyntaxLine;
36
- //# sourceMappingURL=SyntaxLine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_jsxRuntime","e","__esModule","default","SyntaxLine","line","fontSize","jsx","View","style","flexDirection","flexWrap","children","map","token","tokenIndex","content","replace","Text","color","fontFamily","fontStyle","_default","exports"],"sourceRoot":"../../../../src","sources":["components/syntax/SyntaxLine.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAAyC,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAOzC,SAASG,UAAUA,CAAC;EAAEC,IAAI;EAAEC;AAA0B,CAAC,EAAE;EACvD,oBACE,IAAAN,WAAA,CAAAO,GAAA,EAACR,YAAA,CAAAS,IAAI;IAACC,KAAK,EAAE;MAAEC,aAAa,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAO,CAAE;IAAAC,QAAA,EACrDP,IAAI,CAACQ,GAAG,CAAC,CAACC,KAAK,EAAEC,UAAU,KAAK;MAC/B;MACA,MAAMC,OAAO,GAAGF,KAAK,CAACE,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;MACrD,oBACE,IAAAjB,WAAA,CAAAO,GAAA,EAACR,YAAA,CAAAmB,IAAI;QAEHT,KAAK,EAAE;UACLU,KAAK,EAAEL,KAAK,CAACK,KAAK;UAClBC,UAAU,EAAE,WAAW;UACvBd,QAAQ;UACRe,SAAS,EAAEP,KAAK,CAACO;QACnB,CAAE;QAAAT,QAAA,EAEDI;MAAO,GARH,GAAGA,OAAO,IAAID,UAAU,EASzB,CAAC;IAEX,CAAC;EAAC,CACE,CAAC;AAEX;AAAC,IAAAO,QAAA,GAAAC,OAAA,CAAApB,OAAA,GAEcC,UAAU","ignoreList":[]}
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "SyntaxHighlighter", {
7
- enumerable: true,
8
- get: function () {
9
- return _SyntaxHighlighter.default;
10
- }
11
- });
12
- Object.defineProperty(exports, "SyntaxLine", {
13
- enumerable: true,
14
- get: function () {
15
- return _SyntaxLine.default;
16
- }
17
- });
18
- var _SyntaxHighlighter = _interopRequireDefault(require("./SyntaxHighlighter"));
19
- var _SyntaxLine = _interopRequireDefault(require("./SyntaxLine"));
20
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
21
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_SyntaxHighlighter","_interopRequireDefault","require","_SyntaxLine","e","__esModule","default"],"sourceRoot":"../../../../src","sources":["components/syntax/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,kBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoD,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_core","require","_javascript","initializeHighlighter","langs","themes","createHighlighterCore","engine","createJavaScriptRegexEngine","createHighlighter","length","Error","highlighter","error","console","processTokens","tokens","map","token","content","color","fontStyle","toString"],"sourceRoot":"../../../../src","sources":["syntax/highlighter/index.ts"],"mappings":";;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,eAAeE,qBAAqBA,CAACC,KAAsB,EAAEC,MAAoB,EAA8D;EAC7I,OAAO,IAAAC,2BAAqB,EAAC;IAC3BC,MAAM,EAAE,IAAAC,uCAA2B,EAAC,CAAC;IACrCJ,KAAK;IACLC;EACF,CAAC,CAAC;AACJ;AAEO,eAAeI,iBAAiBA,CAAC;EAAEL,KAAK;EAAEC;AAAyD,CAAC,EAA8D;EACvK,IAAI,CAACD,KAAK,EAAEM,MAAM,IAAI,CAACL,MAAM,EAAEK,MAAM,EAAE;IACrC,MAAM,IAAIC,KAAK,CAAC,uEAAuE,CAAC;EAC1F;EAEA,IAAI;IACF,MAAMC,WAAW,GAAG,MAAMT,qBAAqB,CAACC,KAAK,EAAEC,MAAM,CAAC;IAC9D,OAAOO,WAAW;EACpB,CAAC,CACD,OAAOC,KAAK,EAAE;IACZC,OAAO,CAACD,KAAK,CAAC,+BAA+B,EAAEA,KAAK,CAAC;IACrD,MAAMA,KAAK;EACb;AACF;AAEO,SAASE,aAAaA,CAACC,MAAqB,EAAe;EAChE,OAAOA,MAAM,CAACC,GAAG,CAACC,KAAK,KAAK;IAC1BC,OAAO,EAAED,KAAK,CAACC,OAAO;IACtBC,KAAK,EAAEF,KAAK,CAACE,KAAK,IAAI,SAAS;IAC/BC,SAAS,EAAEH,KAAK,CAACG,SAAS,EAAEC,QAAQ,CAAC;EACvC,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "createHighlighter", {
7
- enumerable: true,
8
- get: function () {
9
- return _highlighter.createHighlighter;
10
- }
11
- });
12
- Object.defineProperty(exports, "processTokens", {
13
- enumerable: true,
14
- get: function () {
15
- return _highlighter.processTokens;
16
- }
17
- });
18
- var _highlighter = require("./highlighter");
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_highlighter","require"],"sourceRoot":"../../../src","sources":["syntax/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=shiki.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/shiki.d.ts"],"mappings":"","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _string = require("./string");
7
- Object.keys(_string).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _string[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _string[key];
14
- }
15
- });
16
- });
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_string","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- import React from 'react';
4
- import { Text, View } from 'react-native';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- function SyntaxLine({
7
- line,
8
- fontSize
9
- }) {
10
- return /*#__PURE__*/_jsx(View, {
11
- style: {
12
- flexDirection: 'row',
13
- flexWrap: 'wrap'
14
- },
15
- children: line.map((token, tokenIndex) => {
16
- // Preserve whitespace
17
- const content = token.content.replace(/ /g, '\u00A0');
18
- return /*#__PURE__*/_jsx(Text, {
19
- style: {
20
- color: token.color,
21
- fontFamily: 'monospace',
22
- fontSize,
23
- fontStyle: token.fontStyle
24
- },
25
- children: content
26
- }, `${content}-${tokenIndex}`);
27
- })
28
- });
29
- }
30
- export default SyntaxLine;
31
- //# sourceMappingURL=SyntaxLine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","Text","View","jsx","_jsx","SyntaxLine","line","fontSize","style","flexDirection","flexWrap","children","map","token","tokenIndex","content","replace","color","fontFamily","fontStyle"],"sourceRoot":"../../../../src","sources":["components/syntax/SyntaxLine.tsx"],"mappings":";;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOzC,SAASC,UAAUA,CAAC;EAAEC,IAAI;EAAEC;AAA0B,CAAC,EAAE;EACvD,oBACEH,IAAA,CAACF,IAAI;IAACM,KAAK,EAAE;MAAEC,aAAa,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAO,CAAE;IAAAC,QAAA,EACrDL,IAAI,CAACM,GAAG,CAAC,CAACC,KAAK,EAAEC,UAAU,KAAK;MAC/B;MACA,MAAMC,OAAO,GAAGF,KAAK,CAACE,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;MACrD,oBACEZ,IAAA,CAACH,IAAI;QAEHO,KAAK,EAAE;UACLS,KAAK,EAAEJ,KAAK,CAACI,KAAK;UAClBC,UAAU,EAAE,WAAW;UACvBX,QAAQ;UACRY,SAAS,EAAEN,KAAK,CAACM;QACnB,CAAE;QAAAR,QAAA,EAEDI;MAAO,GARH,GAAGA,OAAO,IAAID,UAAU,EASzB,CAAC;IAEX,CAAC;EAAC,CACE,CAAC;AAEX;AAEA,eAAeT,UAAU","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- export { default as SyntaxHighlighter } from './SyntaxHighlighter';
4
- export { default as SyntaxLine } from './SyntaxLine';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["default","SyntaxHighlighter","SyntaxLine"],"sourceRoot":"../../../../src","sources":["components/syntax/index.ts"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,iBAAiB,QAAQ,qBAAqB;AAClE,SAASD,OAAO,IAAIE,UAAU,QAAQ,cAAc","ignoreList":[]}