Skip to content

Commit 2e8f479

Browse files
committed
Merge branch 'work' into ci/test-satori
2 parents e9f3aca + a61c684 commit 2e8f479

8 files changed

Lines changed: 688 additions & 403 deletions

File tree

src/GZCTF/ClientApp/package.json

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
"dependencies": {
1515
"@babel/core": "^7.27.4",
1616
"@emotion/react": "^11.14.0",
17-
"@mantine/carousel": "^8.0.2",
18-
"@mantine/colors-generator": "^8.0.2",
19-
"@mantine/core": "^8.0.2",
20-
"@mantine/dates": "^8.0.2",
21-
"@mantine/dropzone": "^8.0.2",
22-
"@mantine/emotion": "^8.0.2",
23-
"@mantine/form": "^8.0.2",
24-
"@mantine/hooks": "^8.0.2",
25-
"@mantine/modals": "^8.0.2",
26-
"@mantine/notifications": "^8.0.2",
17+
"@mantine/carousel": "^8.1.0",
18+
"@mantine/colors-generator": "^8.1.0",
19+
"@mantine/core": "^8.1.0",
20+
"@mantine/dates": "^8.1.0",
21+
"@mantine/dropzone": "^8.1.0",
22+
"@mantine/emotion": "^8.1.0",
23+
"@mantine/form": "^8.1.0",
24+
"@mantine/hooks": "^8.1.0",
25+
"@mantine/modals": "^8.1.0",
26+
"@mantine/notifications": "^8.1.0",
2727
"@marsidev/react-turnstile": "^1.1.0",
2828
"@mdi/js": "^7.4.47",
2929
"@mdi/react": "^1.6.1",
@@ -44,46 +44,45 @@
4444
"katex": "^0.16.22",
4545
"lz-string": "^1.5.0",
4646
"marked": "^15.0.12",
47-
"marked-highlight": "^2.2.1",
4847
"pdfjs-dist": "4.8.69",
49-
"prismjs": "^1.30.0",
5048
"react": "^19.1.0",
5149
"react-dom": "^19.1.0",
5250
"react-error-boundary": "^6.0.0",
5351
"react-i18next": "^15.5.2",
5452
"react-pdf": "^9.2.1",
5553
"react-router": "^7.6.2",
54+
"shiki": "^3.6.0",
5655
"swr": "^2.3.3"
5756
},
5857
"devDependencies": {
58+
"@shikijs/transformers": "^3.6.0",
5959
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
6060
"@types/chroma-js": "^3.1.1",
6161
"@types/katex": "^0.16.7",
62-
"@types/node": "^22.15.30",
62+
"@types/node": "^24.0.0",
6363
"@types/prismjs": "^1.26.5",
64-
"@types/react": "^19.1.6",
64+
"@types/react": "^19.1.7",
6565
"@types/react-dom": "^19.1.6",
66-
"@vitejs/plugin-react": "^4.5.1",
66+
"@vitejs/plugin-react": "^4.5.2",
6767
"axios": "^1.9.0",
6868
"babel-plugin-prismjs": "^2.1.0",
6969
"form-data": "~4.0.3",
7070
"globals": "^16.2.0",
7171
"lodash": "^4.17.21",
72-
"oxlint": "^0.18.0",
72+
"oxlint": "^1.0.0",
7373
"postcss": "^8.5.4",
7474
"postcss-preset-mantine": "^1.17.0",
7575
"postcss-simple-vars": "^7.0.1",
7676
"prettier": "~3.5.3",
7777
"prettier-plugin-sort-json": "^4.1.1",
7878
"rollup": "^4.42.0",
79-
"swagger-typescript-api": "^13.2.0",
79+
"swagger-typescript-api": "^13.2.1",
8080
"tslib": "^2.8.1",
8181
"typescript": "5.8.3",
8282
"vite": "npm:rolldown-vite@^6.3.18",
8383
"vite-plugin-banner": "^0.8.1",
8484
"vite-plugin-optimize-css-modules": "^1.2.0",
8585
"vite-plugin-pages": "^0.33.0",
86-
"vite-plugin-prismjs": "^0.0.11",
8786
"vite-plugin-webfont-dl": "^3.10.5",
8887
"vite-tsconfig-paths": "^5.1.4"
8988
},

src/GZCTF/ClientApp/pnpm-lock.yaml

Lines changed: 565 additions & 271 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { Text, TextProps, TypographyStylesProvider } from '@mantine/core'
22
import 'katex/dist/katex.min.css'
33
import { Marked } from 'marked'
4-
import { markedHighlight } from 'marked-highlight'
5-
import Prism from 'prismjs'
6-
import { forwardRef } from 'react'
7-
import { KatexExtension } from '@Utils/KatexExtension'
4+
import { forwardRef, useMemo, use } from 'react'
5+
import { KatexExtension } from '@Utils/marked/KatexExtension'
6+
import { ShikiExtension } from '@Utils/marked/ShikiExtension'
87
import classes from '@Styles/Typography.module.css'
98

109
export interface MarkdownProps extends React.ComponentPropsWithoutRef<'div'> {
@@ -17,19 +16,20 @@ interface InlineMarkdownProps extends TextProps {
1716

1817
export const InlineMarkdown = forwardRef<HTMLParagraphElement, InlineMarkdownProps>((props, ref) => {
1918
const { source, ...others } = props
20-
const marked = new Marked()
2119

22-
marked.use(KatexExtension()).setOptions({
23-
silent: true,
24-
})
20+
const inlineMarked = useMemo(() => {
21+
const instance = new Marked()
22+
instance.use(KatexExtension()).setOptions({ silent: true })
23+
return instance
24+
}, [])
2525

2626
return (
2727
<Text
2828
ref={ref}
2929
{...others}
3030
className={classes.inline}
3131
dangerouslySetInnerHTML={{
32-
__html: marked.parseInline(source) ?? '',
32+
__html: inlineMarked.parseInline(source) ?? '',
3333
}}
3434
/>
3535
)
@@ -38,27 +38,21 @@ export const InlineMarkdown = forwardRef<HTMLParagraphElement, InlineMarkdownPro
3838
export const Markdown = forwardRef<HTMLDivElement, MarkdownProps>((props, ref) => {
3939
const { source, ...others } = props
4040

41-
Prism.manual = true
41+
const marked = useMemo(() => {
42+
const instance = new Marked()
43+
instance.use(KatexExtension()).use(ShikiExtension()).setOptions({ silent: true })
44+
return instance
45+
}, [])
4246

43-
const marked = new Marked(
44-
markedHighlight({
45-
highlight(code, lang) {
46-
if (lang && Prism.languages[lang]) {
47-
return Prism.highlight(code, Prism.languages[lang], lang)
48-
} else {
49-
return code
50-
}
51-
},
52-
})
53-
)
47+
const htmlPromise = useMemo(() => {
48+
return marked.parse(source) as Promise<string>
49+
}, [marked, source])
5450

55-
marked.use(KatexExtension()).setOptions({
56-
silent: true,
57-
})
51+
const resolvedHtml = use(htmlPromise)
5852

5953
return (
6054
<TypographyStylesProvider ref={ref} {...others}>
61-
<div className={classes.root} dangerouslySetInnerHTML={{ __html: marked.parse(source) }} />
55+
<div className={classes.root} dangerouslySetInnerHTML={{ __html: resolvedHtml }} />
6256
</TypographyStylesProvider>
6357
)
6458
})

src/GZCTF/ClientApp/src/components/WsrxProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { mdiClose } from '@mdi/js'
44
import { Icon } from '@mdi/react'
55
import { Wsrx, WsrxError, WsrxErrorKind, WsrxFeature, WsrxOptions, WsrxState } from '@xdsec/wsrx'
66
import { t } from 'i18next'
7-
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
7+
import { createContext, useCallback, use, useEffect, useMemo, useState } from 'react'
88
import { showErrorMsg } from '@Utils/Shared'
99
import { useConfig } from '@Hooks/useConfig'
1010

@@ -159,7 +159,7 @@ export const WsrxProvider: React.FC<React.PropsWithChildren> = ({ children }) =>
159159
}
160160

161161
export const useWsrx = () => {
162-
const context = useContext(WsrxContext)
162+
const context = use(WsrxContext)
163163
if (!context) {
164164
throw new Error('useWsrx must be used within a WsrxProvider')
165165
}

src/GZCTF/ClientApp/src/styles/shared/Typography.module.css

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -85,85 +85,6 @@
8585
line-height: var(--mantine-line-height-sm);
8686
tab-size: 4;
8787
hyphens: none;
88-
89-
& :global(.namespace) {
90-
opacity: 0.8;
91-
}
92-
93-
& :global(.token.id),
94-
& :global(.token.important),
95-
& :global(.token.keyword) {
96-
font-weight: bold;
97-
}
98-
99-
& :global(.token.atrule),
100-
& :global(.token.boolean),
101-
& :global(.token.constant),
102-
& :global(.token.function),
103-
& :global(.token.id),
104-
& :global(.token.important),
105-
& :global(.token.keyword),
106-
& :global(.token.symbol) {
107-
color: light-dark(#7c4dff, #c792ea);
108-
}
109-
110-
& :global(.token.attr-name),
111-
& :global(.token.builtin),
112-
& :global(.token.class) {
113-
color: light-dark(#39adb5, #ffcb6b);
114-
}
115-
116-
& :global(.token.attr-value),
117-
& :global(.token.attribute),
118-
& :global(.token.pseudo-class),
119-
& :global(.token.pseudo-element) {
120-
color: light-dark(#f6a434, #a5e844);
121-
}
122-
123-
& :global(.token.cdata),
124-
& :global(.token.char),
125-
& :global(.token.inserted),
126-
& :global(.token.operator),
127-
& :global(.token.property) {
128-
color: light-dark(#39adb5, #80cbc4);
129-
}
130-
131-
& :global(.token.class-name),
132-
& :global(.token.regex) {
133-
color: light-dark(#6182b8, #f2ff00);
134-
}
135-
136-
& :global(.token.comment),
137-
& :global(.token.doctype),
138-
& :global(.token.prolog) {
139-
color: light-dark(#aabfc9, #616161);
140-
}
141-
142-
& :global(.token.deleted),
143-
& :global(.token.entity),
144-
& :global(.token.selector),
145-
& :global(.token.category),
146-
& :global(.token.url),
147-
& :global(.token.variable) {
148-
color: light-dark(#e53935, #ff6666);
149-
}
150-
151-
& :global(.token.hexcode) {
152-
color: light-dark(#f76d47, #f2ff00);
153-
}
154-
155-
& :global(.token.number),
156-
& :global(.token.unit) {
157-
color: light-dark(#f76d47, #fd9170);
158-
}
159-
160-
& :global(.token.punctuation) {
161-
color: light-dark(#39adb5, #89ddff);
162-
}
163-
164-
& :global(.token.string) {
165-
color: light-dark(#84a657, #a5e844);
166-
}
16788
}
16889
}
16990

File renamed without changes.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import {
2+
transformerNotationDiff,
3+
transformerNotationHighlight,
4+
transformerNotationWordHighlight,
5+
transformerNotationFocus,
6+
transformerNotationErrorLevel,
7+
} from '@shikijs/transformers'
8+
import type { MarkedExtension, Token } from 'marked'
9+
import { createHighlighter } from 'shiki'
10+
11+
const highlighter = await createHighlighter({
12+
langs: [
13+
'astro',
14+
'c',
15+
'cpp',
16+
'csharp',
17+
'c#',
18+
'cs',
19+
'css',
20+
'dart',
21+
'docker',
22+
'dockerfile',
23+
'graphql',
24+
'gql',
25+
'fsharp',
26+
'gdscript',
27+
'glsl',
28+
'bash',
29+
'go',
30+
'html',
31+
'javascript',
32+
'json',
33+
'latex',
34+
'markdown',
35+
'mdx',
36+
'plsql',
37+
'prisma',
38+
'powershell',
39+
'python',
40+
'rust',
41+
'sql',
42+
'svelte',
43+
'toml',
44+
'yaml',
45+
'vue',
46+
'typescript',
47+
'xml',
48+
],
49+
themes: ['material-theme-darker', 'material-theme-lighter'],
50+
})
51+
52+
const highlight = async (code: string, lang: string) => {
53+
return highlighter.codeToHtml(code, {
54+
lang,
55+
themes: {
56+
dark: 'material-theme-darker',
57+
light: 'material-theme-lighter',
58+
},
59+
defaultColor: 'light-dark()',
60+
transformers: [
61+
transformerNotationDiff(),
62+
transformerNotationHighlight(),
63+
transformerNotationWordHighlight(),
64+
transformerNotationFocus(),
65+
transformerNotationErrorLevel(),
66+
],
67+
})
68+
}
69+
70+
export function ShikiExtension(): MarkedExtension {
71+
return {
72+
async: true,
73+
walkTokens: async (token: Token) => {
74+
if (token.type !== 'code') return
75+
76+
const { lang = 'text', text } = token
77+
78+
Object.assign(token, {
79+
type: 'html',
80+
block: true,
81+
text: await highlight(text, lang),
82+
})
83+
},
84+
}
85+
}

src/GZCTF/ClientApp/vite.config.mts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { defineConfig, loadEnv } from 'vite'
44
import banner from 'vite-plugin-banner'
55
import { optimizeCssModules } from 'vite-plugin-optimize-css-modules'
66
import Pages from 'vite-plugin-pages'
7-
import { prismjsPlugin } from 'vite-plugin-prismjs'
87
import webfontDownload from 'vite-plugin-webfont-dl'
98
import tsconfigPaths from 'vite-tsconfig-paths'
109
import i18nVirtualManifest from './plugins/vite-i18n-virtual-manifest'
@@ -76,15 +75,8 @@ export default defineConfig(({ mode }) => {
7675
},
7776
],
7877
}),
79-
prismjsPlugin({
80-
languages: 'all',
81-
css: true,
82-
}),
8378
i18nVirtualManifest(),
8479
optimizeCssModules(),
8580
],
86-
experimental: {
87-
enableNativePlugin: true,
88-
},
8981
}
9082
})

0 commit comments

Comments
 (0)