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.
- 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 +85 -33
- 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,81 @@ 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,
|
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,
|
36
|
-
const
|
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:
|
45
|
-
const
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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={
|
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:
|
62
|
-
<View key={lineIndex} style={
|
63
|
-
{
|
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
|
-
|
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 {
|
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 {
|
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":[]}
|