rn-shiki 0.0.37-3 → 0.0.37-30
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/components/syntax/SyntaxHighlighter.js +100 -60
- package/lib/commonjs/components/syntax/SyntaxHighlighter.js.map +1 -1
- package/lib/commonjs/hooks/useSyntaxHighlighter.js +18 -10
- package/lib/commonjs/hooks/useSyntaxHighlighter.js.map +1 -1
- package/lib/commonjs/index.js +0 -23
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/syntax/{highlighter/index.js → highlighter.js} +20 -10
- package/lib/commonjs/syntax/highlighter.js.map +1 -0
- package/lib/commonjs/utils/style-transformer.js +103 -0
- package/lib/commonjs/utils/style-transformer.js.map +1 -0
- package/lib/module/components/syntax/SyntaxHighlighter.js +100 -61
- package/lib/module/components/syntax/SyntaxHighlighter.js.map +1 -1
- package/lib/module/hooks/useSyntaxHighlighter.js +17 -9
- package/lib/module/hooks/useSyntaxHighlighter.js.map +1 -1
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/syntax/highlighter.js +44 -0
- package/lib/module/syntax/highlighter.js.map +1 -0
- package/lib/module/utils/style-transformer.js +98 -0
- package/lib/module/utils/style-transformer.js.map +1 -0
- package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts +2 -10
- package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts.map +1 -1
- package/lib/typescript/hooks/useSyntaxHighlighter.d.ts +3 -2
- package/lib/typescript/hooks/useSyntaxHighlighter.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/syntax/{highlighter/index.d.ts → highlighter.d.ts} +3 -4
- package/lib/typescript/syntax/highlighter.d.ts.map +1 -0
- package/lib/typescript/types/shiki.d.ts +10 -8
- package/lib/typescript/types/shiki.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +1 -1
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/lib/typescript/utils/style-transformer.d.ts +9 -0
- package/lib/typescript/utils/style-transformer.d.ts.map +1 -0
- package/package.json +2 -6
- package/src/components/syntax/SyntaxHighlighter.tsx +79 -36
- package/src/hooks/useSyntaxHighlighter.ts +13 -4
- package/src/index.ts +1 -4
- package/src/syntax/{highlighter/index.ts → highlighter.ts} +22 -10
- package/src/types/shiki.ts +7 -8
- package/src/utils/string.ts +1 -1
- package/src/utils/style-transformer.ts +50 -94
- package/lib/commonjs/components/syntax/SyntaxLine.js +0 -36
- package/lib/commonjs/components/syntax/SyntaxLine.js.map +0 -1
- package/lib/commonjs/components/syntax/index.js +0 -21
- package/lib/commonjs/components/syntax/index.js.map +0 -1
- package/lib/commonjs/syntax/highlighter/index.js.map +0 -1
- package/lib/commonjs/syntax/index.js +0 -19
- package/lib/commonjs/syntax/index.js.map +0 -1
- package/lib/commonjs/types/index.js +0 -2
- package/lib/commonjs/types/index.js.map +0 -1
- package/lib/commonjs/types/shiki.d.js +0 -6
- package/lib/commonjs/types/shiki.d.js.map +0 -1
- package/lib/commonjs/utils/index.js +0 -17
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/module/components/syntax/SyntaxLine.js +0 -31
- package/lib/module/components/syntax/SyntaxLine.js.map +0 -1
- package/lib/module/components/syntax/index.js +0 -5
- package/lib/module/components/syntax/index.js.map +0 -1
- package/lib/module/syntax/highlighter/index.js +0 -34
- package/lib/module/syntax/highlighter/index.js.map +0 -1
- package/lib/module/syntax/index.js +0 -4
- package/lib/module/syntax/index.js.map +0 -1
- package/lib/module/types/index.js +0 -2
- package/lib/module/types/index.js.map +0 -1
- package/lib/module/types/shiki.d.js +0 -4
- package/lib/module/types/shiki.d.js.map +0 -1
- package/lib/module/utils/index.js +0 -4
- package/lib/module/utils/index.js.map +0 -1
- package/lib/typescript/components/syntax/SyntaxLine.d.ts +0 -9
- package/lib/typescript/components/syntax/SyntaxLine.d.ts.map +0 -1
- package/lib/typescript/components/syntax/index.d.ts +0 -3
- package/lib/typescript/components/syntax/index.d.ts.map +0 -1
- package/lib/typescript/syntax/highlighter/index.d.ts.map +0 -1
- package/lib/typescript/syntax/index.d.ts +0 -2
- package/lib/typescript/syntax/index.d.ts.map +0 -1
- package/lib/typescript/types/index.d.ts +0 -7
- package/lib/typescript/types/index.d.ts.map +0 -1
- package/lib/typescript/utils/index.d.ts +0 -2
- package/lib/typescript/utils/index.d.ts.map +0 -1
- package/src/components/syntax/SyntaxLine.tsx +0 -81
- package/src/components/syntax/index.ts +0 -2
- package/src/syntax/index.ts +0 -1
- package/src/types/index.ts +0 -6
- package/src/utils/index.ts +0 -1
@@ -1,7 +1,10 @@
|
|
1
|
-
import
|
2
|
-
import
|
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 {
|
7
|
+
import { getRNStylesFromShikiStyle } from '../../utils/style-transformer'
|
5
8
|
|
6
9
|
const monospaceFont = Platform.select({
|
7
10
|
ios: 'Menlo',
|
@@ -9,31 +12,68 @@ const monospaceFont = Platform.select({
|
|
9
12
|
default: 'monospace',
|
10
13
|
})
|
11
14
|
|
12
|
-
interface
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
-
|
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,
|
25
|
-
|
26
|
-
contentContainer: {
|
27
|
-
flexGrow: 1,
|
35
|
+
backgroundColor: '#1e1e1e',
|
28
36
|
},
|
29
37
|
lineContainer: {
|
30
38
|
flexDirection: 'row',
|
31
39
|
flexWrap: 'wrap',
|
40
|
+
minWidth: '100%',
|
41
|
+
paddingHorizontal: 16,
|
42
|
+
paddingVertical: 4,
|
43
|
+
},
|
44
|
+
token: {
|
45
|
+
fontFamily: monospaceFont,
|
46
|
+
fontSize: 14,
|
47
|
+
color: '#d4d4d4',
|
48
|
+
},
|
49
|
+
container: {
|
50
|
+
paddingVertical: 8,
|
51
|
+
},
|
52
|
+
line: {
|
53
|
+
flexDirection: 'row',
|
54
|
+
flexWrap: 'wrap',
|
55
|
+
width: '100%',
|
32
56
|
},
|
33
57
|
})
|
34
58
|
|
35
|
-
const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ text, language, languageId, theme,
|
36
|
-
const
|
59
|
+
const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ text, language, languageId, theme, fontSize = 14 }) => {
|
60
|
+
const stylesheet = useMemo(() => {
|
61
|
+
const themeRegistration = getThemeRegistration(theme)
|
62
|
+
const styles = getRNStylesFromShikiStyle(themeRegistration)
|
63
|
+
|
64
|
+
return StyleSheet.create({
|
65
|
+
...styles,
|
66
|
+
editor: {
|
67
|
+
backgroundColor: themeRegistration.colors?.['editor.background'] || '#1e1e1e',
|
68
|
+
},
|
69
|
+
token: {
|
70
|
+
...baseStyles.token,
|
71
|
+
fontSize,
|
72
|
+
color: themeRegistration.colors?.['editor.foreground'] || '#d4d4d4',
|
73
|
+
},
|
74
|
+
})
|
75
|
+
}, [theme, fontSize])
|
76
|
+
|
37
77
|
const { tokens } = useSyntaxHighlighter({
|
38
78
|
text,
|
39
79
|
language,
|
@@ -41,38 +81,41 @@ const SyntaxHighlighter: React.FC<SyntaxHighlighterProps> = ({ text, language, l
|
|
41
81
|
theme,
|
42
82
|
})
|
43
83
|
|
44
|
-
const renderToken = (token:
|
45
|
-
const
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
84
|
+
const renderToken = (token: ThemedToken, index: number) => {
|
85
|
+
const styles: StyleProp<TokenStyle>[] = [stylesheet.token]
|
86
|
+
|
87
|
+
// Always apply the token color if it exists
|
88
|
+
if (token.color) {
|
89
|
+
styles.push({ color: token.color })
|
90
|
+
}
|
91
|
+
|
92
|
+
// Add font styles
|
93
|
+
if (token.fontStyle) {
|
94
|
+
styles.push({
|
95
|
+
// fontStyle: token.fontStyle.includes('italic') ? 'italic' : 'normal',
|
96
|
+
// fontWeight: token.fontStyle.includes('bold') ? 'bold' : 'normal',
|
97
|
+
fontStyle: token.fontStyle as unknown as 'normal' | 'italic',
|
98
|
+
fontWeight: (token.fontStyle as unknown as string).includes('bold') ? 'bold' : 'normal',
|
99
|
+
})
|
52
100
|
}
|
53
101
|
|
54
102
|
return (
|
55
|
-
<Text key={
|
103
|
+
<Text key={index} style={styles}>
|
56
104
|
{token.content.replace(/ /g, '\u00A0')}
|
57
105
|
</Text>
|
58
106
|
)
|
59
107
|
}
|
60
108
|
|
61
|
-
const renderLine = (line:
|
62
|
-
<View key={lineIndex} style={
|
63
|
-
{line.map((token, tokenIndex) => renderToken(token, tokenIndex
|
109
|
+
const renderLine = (line: ThemedToken[], lineIndex: number) => (
|
110
|
+
<View key={lineIndex} style={baseStyles.line}>
|
111
|
+
{line.map((token, tokenIndex) => renderToken(token, tokenIndex))}
|
112
|
+
<Text>{'\n'}</Text>
|
64
113
|
</View>
|
65
114
|
)
|
66
115
|
|
67
116
|
return (
|
68
|
-
<ScrollView
|
69
|
-
|
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>
|
117
|
+
<ScrollView horizontal showsHorizontalScrollIndicator={Platform.OS !== 'web'} style={[baseStyles.scrollView, stylesheet.editor]} contentContainerStyle={baseStyles.container}>
|
118
|
+
<View>{tokens.map((line, index) => renderLine(line, index))}</View>
|
76
119
|
</ScrollView>
|
77
120
|
)
|
78
121
|
}
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import type {
|
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:
|
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:
|
38
|
+
theme: themeResolved,
|
30
39
|
}) as TokensResult
|
31
40
|
|
32
41
|
if (mounted && result.tokens) {
|
package/src/index.ts
CHANGED
@@ -1,19 +1,31 @@
|
|
1
1
|
import type { LanguageInput, ThemedToken, ThemeInput } from 'shiki'
|
2
|
-
import type { TokenType } from '
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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[] })
|
15
|
-
if (!langs?.length
|
16
|
-
throw new Error('Please provide
|
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 {
|
package/src/types/shiki.ts
CHANGED
@@ -1,20 +1,19 @@
|
|
1
|
-
import type { LanguageInput,
|
1
|
+
import type { LanguageInput, ThemedToken, ThemeInput } from 'shiki'
|
2
2
|
|
3
|
-
export interface
|
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
|
13
|
+
theme: ThemeInput
|
19
14
|
fontSize?: number
|
20
15
|
}
|
16
|
+
|
17
|
+
export interface TokensResult {
|
18
|
+
tokens: ThemedToken[][]
|
19
|
+
}
|
package/src/utils/string.ts
CHANGED
@@ -1,108 +1,64 @@
|
|
1
|
-
import type {
|
2
|
-
import {
|
1
|
+
import type { TextStyle } from 'react-native'
|
2
|
+
import type { ThemeRegistration } from 'shiki'
|
3
3
|
|
4
4
|
export interface HighlighterStyleSheet {
|
5
|
-
|
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
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}
|
10
|
+
function normalizeColor(color: string | undefined): string {
|
11
|
+
if (!color)
|
12
|
+
return 'transparent'
|
13
|
+
return color
|
14
|
+
}
|
31
15
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
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
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
|
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 (error) {
|
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 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
|
@@ -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 +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":[]}
|