@opencode/ui 0.0.0-reserved → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/actions/button/button.d.ts +10 -0
- package/dist/actions/icon-button/icon-button.d.ts +11 -0
- package/dist/actions/split-button/split-button.d.ts +5 -0
- package/dist/components/animated-number.d.ts +4 -0
- package/dist/components/app-icon.d.ts +6 -0
- package/dist/components/app-icons/types.d.ts +2 -0
- package/dist/components/card.d.ts +22 -0
- package/dist/components/collapsible.d.ts +17 -0
- package/dist/components/context-menu.d.ts +80 -0
- package/dist/components/dock-surface.d.ts +7 -0
- package/dist/components/favicon.d.ts +1 -0
- package/dist/components/file-icon.d.ts +12 -0
- package/dist/components/file-icons/types.d.ts +2 -0
- package/dist/components/font.d.ts +1 -0
- package/dist/components/hover-card.d.ts +9 -0
- package/dist/components/image-preview.d.ts +5 -0
- package/dist/components/list.d.ts +45 -0
- package/dist/components/logo.d.ts +8 -0
- package/dist/components/motion-spring.d.ts +4 -0
- package/dist/components/popover.d.ts +14 -0
- package/dist/components/progress.d.ts +7 -0
- package/dist/components/provider-icon.d.ts +5 -0
- package/dist/components/provider-icons/types.d.ts +2 -0
- package/dist/components/resize-handle.d.ts +14 -0
- package/dist/components/scroll-view.d.ts +42 -0
- package/dist/components/spinner.d.ts +6 -0
- package/dist/components/sticky-accordion-header.d.ts +5 -0
- package/dist/components/text-field.d.ts +13 -0
- package/dist/components/text-reveal.d.ts +13 -0
- package/dist/components/text-strikethrough.d.ts +11 -0
- package/dist/components/typewriter.d.ts +6 -0
- package/dist/context/dialog.d.ts +18 -0
- package/dist/context/file.d.ts +5 -0
- package/dist/context/helper.d.ts +14 -0
- package/dist/context/i18n.d.ts +24 -0
- package/dist/context/index.d.ts +4 -0
- package/dist/context/marked-base.d.ts +3 -0
- package/dist/context/marked-parser.d.ts +1 -0
- package/dist/context/marked-theme-register.d.ts +1 -0
- package/dist/context/marked-theme.d.ts +2 -0
- package/dist/context/marked.d.ts +2 -0
- package/dist/context/worker-pool.d.ts +9 -0
- package/dist/data-display/accordion/accordion.d.ts +24 -0
- package/dist/data-display/avatar/avatar.d.ts +11 -0
- package/dist/data-display/badge/badge.d.ts +7 -0
- package/dist/data-display/diff-changes/diff-changes.d.ts +12 -0
- package/dist/data-display/keybind/keybind.d.ts +7 -0
- package/dist/data-display/line-comment/line-comment.d.ts +32 -0
- package/dist/data-display/project-avatar/project-avatar.d.ts +12 -0
- package/dist/feedback/loader/loader.d.ts +3 -0
- package/dist/feedback/progress-circle/progress-circle.d.ts +9 -0
- package/dist/feedback/toast/toast.d.ts +57 -0
- package/dist/forms/checkbox/checkbox.d.ts +8 -0
- package/dist/forms/field/field.d.ts +22 -0
- package/dist/forms/inline-input/inline-input.d.ts +5 -0
- package/dist/forms/radio/radio.d.ts +16 -0
- package/dist/forms/select/select.d.ts +23 -0
- package/dist/forms/switch/switch.d.ts +9 -0
- package/dist/forms/text-input/text-input.d.ts +24 -0
- package/dist/forms/textarea/textarea.d.ts +7 -0
- package/dist/hooks/create-auto-scroll.d.ts +17 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/use-filtered-list.d.ts +48 -0
- package/dist/i18n/am.d.ts +1 -0
- package/dist/i18n/ar.d.ts +209 -0
- package/dist/i18n/az.d.ts +1 -0
- package/dist/i18n/bg.d.ts +193 -0
- package/dist/i18n/bn.d.ts +1 -0
- package/dist/i18n/br.d.ts +197 -0
- package/dist/i18n/bs.d.ts +197 -0
- package/dist/i18n/ca.d.ts +1 -0
- package/dist/i18n/cs.d.ts +1 -0
- package/dist/i18n/da.d.ts +193 -0
- package/dist/i18n/de.d.ts +193 -0
- package/dist/i18n/dv.d.ts +1 -0
- package/dist/i18n/dz.d.ts +1 -0
- package/dist/i18n/el.d.ts +1 -0
- package/dist/i18n/en.d.ts +251 -0
- package/dist/i18n/es.d.ts +197 -0
- package/dist/i18n/et.d.ts +1 -0
- package/dist/i18n/fa.d.ts +1 -0
- package/dist/i18n/fi.d.ts +1 -0
- package/dist/i18n/fo.d.ts +1 -0
- package/dist/i18n/fr.d.ts +197 -0
- package/dist/i18n/he.d.ts +197 -0
- package/dist/i18n/hi.d.ts +1 -0
- package/dist/i18n/hr.d.ts +1 -0
- package/dist/i18n/hu.d.ts +1 -0
- package/dist/i18n/hy.d.ts +1 -0
- package/dist/i18n/id.d.ts +1 -0
- package/dist/i18n/is.d.ts +1 -0
- package/dist/i18n/it.d.ts +1 -0
- package/dist/i18n/ja.d.ts +193 -0
- package/dist/i18n/ka.d.ts +1 -0
- package/dist/i18n/km.d.ts +193 -0
- package/dist/i18n/ko.d.ts +193 -0
- package/dist/i18n/lo.d.ts +193 -0
- package/dist/i18n/lt.d.ts +1 -0
- package/dist/i18n/lv.d.ts +1 -0
- package/dist/i18n/mk.d.ts +193 -0
- package/dist/i18n/mn.d.ts +193 -0
- package/dist/i18n/ms.d.ts +1 -0
- package/dist/i18n/my.d.ts +193 -0
- package/dist/i18n/ne.d.ts +1 -0
- package/dist/i18n/nl.d.ts +1 -0
- package/dist/i18n/no.d.ts +4 -0
- package/dist/i18n/pa.d.ts +1 -0
- package/dist/i18n/pl.d.ts +201 -0
- package/dist/i18n/ro.d.ts +1 -0
- package/dist/i18n/ru.d.ts +201 -0
- package/dist/i18n/si.d.ts +1 -0
- package/dist/i18n/sk.d.ts +1 -0
- package/dist/i18n/sl.d.ts +1 -0
- package/dist/i18n/sq.d.ts +1 -0
- package/dist/i18n/sr.d.ts +197 -0
- package/dist/i18n/sv.d.ts +1 -0
- package/dist/i18n/tg.d.ts +193 -0
- package/dist/i18n/th.d.ts +193 -0
- package/dist/i18n/tk.d.ts +1 -0
- package/dist/i18n/tr.d.ts +193 -0
- package/dist/i18n/uk.d.ts +1 -0
- package/dist/i18n/ur.d.ts +1 -0
- package/dist/i18n/uz.d.ts +1 -0
- package/dist/i18n/vi.d.ts +1 -0
- package/dist/i18n/zh.d.ts +193 -0
- package/dist/i18n/zht.d.ts +193 -0
- package/dist/icons/icon/additional-icons.d.ts +105 -0
- package/dist/icons/icon/icon.d.ts +228 -0
- package/dist/layout/divider/divider.d.ts +5 -0
- package/dist/navigation/menu/menu.d.ts +59 -0
- package/dist/navigation/segmented-control/segmented-control.d.ts +21 -0
- package/dist/navigation/tab-state-indicator.d.ts +2 -0
- package/dist/navigation/tabs/tabs.d.ts +39 -0
- package/dist/overlays/dialog/dialog.d.ts +26 -0
- package/dist/overlays/tooltip/tooltip.d.ts +15 -0
- package/dist/storybook/fixtures.d.ts +19 -0
- package/dist/storybook/scaffold.d.ts +16 -0
- package/dist/theme/color.d.ts +30 -0
- package/dist/theme/context.d.ts +21 -0
- package/dist/theme/default-themes.d.ts +39 -0
- package/dist/theme/index.d.ts +7 -0
- package/dist/theme/loader.d.ts +6 -0
- package/dist/theme/resolve.d.ts +7 -0
- package/dist/theme/types.d.ts +56 -0
- package/dist/theme/v2/avatar.d.ts +5 -0
- package/dist/theme/v2/default-primitives.d.ts +3 -0
- package/dist/theme/v2/foreground.d.ts +2 -0
- package/dist/theme/v2/mapping.d.ts +3 -0
- package/dist/theme/v2/resolve.d.ts +9 -0
- package/dist/typography/text-shimmer/text-shimmer.d.ts +9 -0
- package/dist/typography/wordmark/wordmark.d.ts +5 -0
- package/package.json +252 -6
- package/src/actions/button/button.css +294 -0
- package/src/actions/button/button.tsx +42 -0
- package/src/actions/icon-button/icon-button.css +124 -0
- package/src/actions/icon-button/icon-button.tsx +32 -0
- package/src/actions/split-button/split-button.css +95 -0
- package/src/actions/split-button/split-button.tsx +48 -0
- package/src/actions/submit.css +74 -0
- package/src/assets/audio/alert-01.aac +0 -0
- package/src/assets/audio/alert-01.mp3 +0 -0
- package/src/assets/audio/alert-02.aac +0 -0
- package/src/assets/audio/alert-02.mp3 +0 -0
- package/src/assets/audio/alert-03.aac +0 -0
- package/src/assets/audio/alert-03.mp3 +0 -0
- package/src/assets/audio/alert-04.aac +0 -0
- package/src/assets/audio/alert-04.mp3 +0 -0
- package/src/assets/audio/alert-05.aac +0 -0
- package/src/assets/audio/alert-05.mp3 +0 -0
- package/src/assets/audio/alert-06.aac +0 -0
- package/src/assets/audio/alert-06.mp3 +0 -0
- package/src/assets/audio/alert-07.aac +0 -0
- package/src/assets/audio/alert-07.mp3 +0 -0
- package/src/assets/audio/alert-08.aac +0 -0
- package/src/assets/audio/alert-08.mp3 +0 -0
- package/src/assets/audio/alert-09.aac +0 -0
- package/src/assets/audio/alert-09.mp3 +0 -0
- package/src/assets/audio/alert-10.aac +0 -0
- package/src/assets/audio/alert-10.mp3 +0 -0
- package/src/assets/audio/bip-bop-01.aac +0 -0
- package/src/assets/audio/bip-bop-01.mp3 +0 -0
- package/src/assets/audio/bip-bop-02.aac +0 -0
- package/src/assets/audio/bip-bop-02.mp3 +0 -0
- package/src/assets/audio/bip-bop-03.aac +0 -0
- package/src/assets/audio/bip-bop-03.mp3 +0 -0
- package/src/assets/audio/bip-bop-04.aac +0 -0
- package/src/assets/audio/bip-bop-04.mp3 +0 -0
- package/src/assets/audio/bip-bop-05.aac +0 -0
- package/src/assets/audio/bip-bop-05.mp3 +0 -0
- package/src/assets/audio/bip-bop-06.aac +0 -0
- package/src/assets/audio/bip-bop-06.mp3 +0 -0
- package/src/assets/audio/bip-bop-07.aac +0 -0
- package/src/assets/audio/bip-bop-07.mp3 +0 -0
- package/src/assets/audio/bip-bop-08.aac +0 -0
- package/src/assets/audio/bip-bop-08.mp3 +0 -0
- package/src/assets/audio/bip-bop-09.aac +0 -0
- package/src/assets/audio/bip-bop-09.mp3 +0 -0
- package/src/assets/audio/bip-bop-10.aac +0 -0
- package/src/assets/audio/bip-bop-10.mp3 +0 -0
- package/src/assets/audio/nope-01.aac +0 -0
- package/src/assets/audio/nope-01.mp3 +0 -0
- package/src/assets/audio/nope-02.aac +0 -0
- package/src/assets/audio/nope-02.mp3 +0 -0
- package/src/assets/audio/nope-03.aac +0 -0
- package/src/assets/audio/nope-03.mp3 +0 -0
- package/src/assets/audio/nope-04.aac +0 -0
- package/src/assets/audio/nope-04.mp3 +0 -0
- package/src/assets/audio/nope-05.aac +0 -0
- package/src/assets/audio/nope-05.mp3 +0 -0
- package/src/assets/audio/nope-06.aac +0 -0
- package/src/assets/audio/nope-06.mp3 +0 -0
- package/src/assets/audio/nope-07.aac +0 -0
- package/src/assets/audio/nope-07.mp3 +0 -0
- package/src/assets/audio/nope-08.aac +0 -0
- package/src/assets/audio/nope-08.mp3 +0 -0
- package/src/assets/audio/nope-09.aac +0 -0
- package/src/assets/audio/nope-09.mp3 +0 -0
- package/src/assets/audio/nope-10.aac +0 -0
- package/src/assets/audio/nope-10.mp3 +0 -0
- package/src/assets/audio/nope-11.aac +0 -0
- package/src/assets/audio/nope-11.mp3 +0 -0
- package/src/assets/audio/nope-12.aac +0 -0
- package/src/assets/audio/nope-12.mp3 +0 -0
- package/src/assets/audio/staplebops-01.aac +0 -0
- package/src/assets/audio/staplebops-01.mp3 +0 -0
- package/src/assets/audio/staplebops-02.aac +0 -0
- package/src/assets/audio/staplebops-02.mp3 +0 -0
- package/src/assets/audio/staplebops-03.aac +0 -0
- package/src/assets/audio/staplebops-03.mp3 +0 -0
- package/src/assets/audio/staplebops-04.aac +0 -0
- package/src/assets/audio/staplebops-04.mp3 +0 -0
- package/src/assets/audio/staplebops-05.aac +0 -0
- package/src/assets/audio/staplebops-05.mp3 +0 -0
- package/src/assets/audio/staplebops-06.aac +0 -0
- package/src/assets/audio/staplebops-06.mp3 +0 -0
- package/src/assets/audio/staplebops-07.aac +0 -0
- package/src/assets/audio/staplebops-07.mp3 +0 -0
- package/src/assets/audio/yup-01.aac +0 -0
- package/src/assets/audio/yup-01.mp3 +0 -0
- package/src/assets/audio/yup-02.aac +0 -0
- package/src/assets/audio/yup-02.mp3 +0 -0
- package/src/assets/audio/yup-03.aac +0 -0
- package/src/assets/audio/yup-03.mp3 +0 -0
- package/src/assets/audio/yup-04.aac +0 -0
- package/src/assets/audio/yup-04.mp3 +0 -0
- package/src/assets/audio/yup-05.aac +0 -0
- package/src/assets/audio/yup-05.mp3 +0 -0
- package/src/assets/audio/yup-06.aac +0 -0
- package/src/assets/audio/yup-06.mp3 +0 -0
- package/src/assets/fonts/Inter.ttf +0 -0
- package/src/assets/fonts/JetBrainsMonoNerdFontMono-Regular.woff2 +0 -0
- package/src/assets/icons/app/android-studio.svg +369 -0
- package/src/assets/icons/app/antigravity.svg +97 -0
- package/src/assets/icons/app/cursor.svg +16 -0
- package/src/assets/icons/app/file-explorer.svg +20 -0
- package/src/assets/icons/app/finder.png +0 -0
- package/src/assets/icons/app/ghostty.svg +13 -0
- package/src/assets/icons/app/iterm2.svg +13 -0
- package/src/assets/icons/app/powershell.svg +14 -0
- package/src/assets/icons/app/sublimetext.svg +17 -0
- package/src/assets/icons/app/terminal.png +0 -0
- package/src/assets/icons/app/textmate.png +0 -0
- package/src/assets/icons/app/vscode.svg +39 -0
- package/src/assets/icons/app/warp.png +0 -0
- package/src/assets/icons/app/xcode.png +0 -0
- package/src/assets/icons/app/zed-dark.svg +15 -0
- package/src/assets/icons/app/zed.svg +15 -0
- package/src/components/animated-number.css +93 -0
- package/src/components/animated-number.tsx +109 -0
- package/src/components/app-icon.css +5 -0
- package/src/components/app-icon.tsx +85 -0
- package/src/components/app-icons/sprite.svg +114 -0
- package/src/components/app-icons/types.ts +21 -0
- package/src/components/card.css +94 -0
- package/src/components/card.tsx +123 -0
- package/src/components/collapsible.css +154 -0
- package/src/components/collapsible.tsx +48 -0
- package/src/components/context-menu.css +134 -0
- package/src/components/context-menu.tsx +308 -0
- package/src/components/dock-surface.css +30 -0
- package/src/components/dock-surface.tsx +54 -0
- package/src/components/favicon.tsx +13 -0
- package/src/components/file-icon.css +26 -0
- package/src/components/file-icon.tsx +588 -0
- package/src/components/file-icons/sprite.svg +11707 -0
- package/src/components/file-icons/types.ts +1095 -0
- package/src/components/font.tsx +1 -0
- package/src/components/hover-card.css +61 -0
- package/src/components/hover-card.tsx +32 -0
- package/src/components/image-preview.css +63 -0
- package/src/components/image-preview.tsx +33 -0
- package/src/components/list.css +331 -0
- package/src/components/list.tsx +396 -0
- package/src/components/logo.css +4 -0
- package/src/components/logo.tsx +62 -0
- package/src/components/motion-spring.tsx +58 -0
- package/src/components/popover.css +98 -0
- package/src/components/popover.tsx +154 -0
- package/src/components/progress.css +63 -0
- package/src/components/progress.tsx +39 -0
- package/src/components/provider-icon.css +5 -0
- package/src/components/provider-icon.tsx +25 -0
- package/src/components/provider-icons/sprite.svg +1110 -0
- package/src/components/provider-icons/types.ts +105 -0
- package/src/components/resize-handle.css +70 -0
- package/src/components/resize-handle.tsx +102 -0
- package/src/components/scroll-view.css +99 -0
- package/src/components/scroll-view.tsx +453 -0
- package/src/components/spinner.css +6 -0
- package/src/components/spinner.tsx +52 -0
- package/src/components/sticky-accordion-header.css +6 -0
- package/src/components/sticky-accordion-header.tsx +18 -0
- package/src/components/text-field.css +134 -0
- package/src/components/text-field.tsx +136 -0
- package/src/components/text-reveal.css +150 -0
- package/src/components/text-reveal.tsx +143 -0
- package/src/components/text-strikethrough.css +27 -0
- package/src/components/text-strikethrough.tsx +84 -0
- package/src/components/typewriter.css +14 -0
- package/src/components/typewriter.tsx +55 -0
- package/src/context/dialog.tsx +198 -0
- package/src/context/file.tsx +10 -0
- package/src/context/helper.tsx +38 -0
- package/src/context/i18n.tsx +77 -0
- package/src/context/index.ts +4 -0
- package/src/context/marked-base.tsx +55 -0
- package/src/context/marked-parser.tsx +58 -0
- package/src/context/marked-theme-register.tsx +10 -0
- package/src/context/marked-theme.tsx +372 -0
- package/src/context/marked.tsx +28 -0
- package/src/context/worker-pool.tsx +20 -0
- package/src/custom-elements.d.ts +17 -0
- package/src/data-display/accordion/accordion.css +121 -0
- package/src/data-display/accordion/accordion.tsx +92 -0
- package/src/data-display/avatar/avatar.css +70 -0
- package/src/data-display/avatar/avatar.tsx +59 -0
- package/src/data-display/badge/badge.css +52 -0
- package/src/data-display/badge/badge.tsx +25 -0
- package/src/data-display/diff-changes/diff-changes.css +47 -0
- package/src/data-display/diff-changes/diff-changes.tsx +33 -0
- package/src/data-display/keybind/keybind.css +76 -0
- package/src/data-display/keybind/keybind.tsx +30 -0
- package/src/data-display/line-comment/line-comment.css +258 -0
- package/src/data-display/line-comment/line-comment.tsx +308 -0
- package/src/data-display/project-avatar/project-avatar.css +132 -0
- package/src/data-display/project-avatar/project-avatar.tsx +66 -0
- package/src/feedback/loader/loader.css +32 -0
- package/src/feedback/loader/loader.tsx +31 -0
- package/src/feedback/progress-circle/progress-circle.css +28 -0
- package/src/feedback/progress-circle/progress-circle.tsx +64 -0
- package/src/feedback/toast/toast.css +225 -0
- package/src/feedback/toast/toast.tsx +283 -0
- package/src/forms/checkbox/checkbox.css +125 -0
- package/src/forms/checkbox/checkbox.tsx +43 -0
- package/src/forms/field/field.css +94 -0
- package/src/forms/field/field.tsx +263 -0
- package/src/forms/inline-input/inline-input.css +17 -0
- package/src/forms/inline-input/inline-input.tsx +22 -0
- package/src/forms/radio/radio.css +202 -0
- package/src/forms/radio/radio.tsx +82 -0
- package/src/forms/select/select.css +290 -0
- package/src/forms/select/select.tsx +219 -0
- package/src/forms/switch/switch.css +272 -0
- package/src/forms/switch/switch.tsx +34 -0
- package/src/forms/text-input/text-input.css +181 -0
- package/src/forms/text-input/text-input.tsx +99 -0
- package/src/forms/textarea/textarea.css +78 -0
- package/src/forms/textarea/textarea.tsx +31 -0
- package/src/hooks/create-auto-scroll.tsx +257 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-filtered-list.tsx +134 -0
- package/src/i18n/am.ts +194 -0
- package/src/i18n/ar.ts +231 -0
- package/src/i18n/az.ts +195 -0
- package/src/i18n/bg.ts +195 -0
- package/src/i18n/bn.ts +197 -0
- package/src/i18n/br.ts +219 -0
- package/src/i18n/bs.ts +223 -0
- package/src/i18n/ca.ts +199 -0
- package/src/i18n/cs.ts +203 -0
- package/src/i18n/da.ts +214 -0
- package/src/i18n/de.ts +219 -0
- package/src/i18n/dv.ts +196 -0
- package/src/i18n/dz.ts +197 -0
- package/src/i18n/el.ts +195 -0
- package/src/i18n/en.ts +276 -0
- package/src/i18n/es.ts +219 -0
- package/src/i18n/et.ts +195 -0
- package/src/i18n/fa.ts +195 -0
- package/src/i18n/fi.ts +195 -0
- package/src/i18n/fo.ts +195 -0
- package/src/i18n/fr.ts +221 -0
- package/src/i18n/he.ts +199 -0
- package/src/i18n/hi.ts +197 -0
- package/src/i18n/hr.ts +200 -0
- package/src/i18n/hu.ts +197 -0
- package/src/i18n/hy.ts +195 -0
- package/src/i18n/id.ts +217 -0
- package/src/i18n/is.ts +195 -0
- package/src/i18n/it.ts +200 -0
- package/src/i18n/ja.ts +214 -0
- package/src/i18n/ka.ts +195 -0
- package/src/i18n/km.ts +196 -0
- package/src/i18n/ko.ts +216 -0
- package/src/i18n/lo.ts +195 -0
- package/src/i18n/lt.ts +203 -0
- package/src/i18n/lv.ts +199 -0
- package/src/i18n/mk.ts +195 -0
- package/src/i18n/mn.ts +195 -0
- package/src/i18n/ms.ts +195 -0
- package/src/i18n/my.ts +196 -0
- package/src/i18n/ne.ts +197 -0
- package/src/i18n/nl.ts +195 -0
- package/src/i18n/no.ts +219 -0
- package/src/i18n/pa.ts +196 -0
- package/src/i18n/pl.ts +223 -0
- package/src/i18n/ro.ts +199 -0
- package/src/i18n/ru.ts +222 -0
- package/src/i18n/si.ts +195 -0
- package/src/i18n/sk.ts +203 -0
- package/src/i18n/sl.ts +204 -0
- package/src/i18n/sq.ts +195 -0
- package/src/i18n/sr.ts +200 -0
- package/src/i18n/sv.ts +195 -0
- package/src/i18n/tg.ts +195 -0
- package/src/i18n/th.ts +215 -0
- package/src/i18n/tk.ts +195 -0
- package/src/i18n/tr.ts +221 -0
- package/src/i18n/uk.ts +226 -0
- package/src/i18n/ur.ts +196 -0
- package/src/i18n/uz.ts +198 -0
- package/src/i18n/vi.ts +195 -0
- package/src/i18n/zh.ts +217 -0
- package/src/i18n/zht.ts +217 -0
- package/src/icons/icon/additional-icons.ts +115 -0
- package/src/icons/icon/icon.css +3 -0
- package/src/icons/icon/icon.tsx +305 -0
- package/src/layout/divider/divider.css +11 -0
- package/src/layout/divider/divider.tsx +20 -0
- package/src/navigation/menu/menu.css +311 -0
- package/src/navigation/menu/menu.tsx +289 -0
- package/src/navigation/segmented-control/segmented-control.css +80 -0
- package/src/navigation/segmented-control/segmented-control.tsx +209 -0
- package/src/navigation/tab-state-indicator.tsx +37 -0
- package/src/navigation/tabs/tabs-current.css +239 -0
- package/src/navigation/tabs/tabs.css +710 -0
- package/src/navigation/tabs/tabs.tsx +194 -0
- package/src/overlays/dialog/dialog.css +180 -0
- package/src/overlays/dialog/dialog.tsx +115 -0
- package/src/overlays/tooltip/tooltip.css +102 -0
- package/src/overlays/tooltip/tooltip.tsx +154 -0
- package/src/storybook/fixtures.ts +51 -0
- package/src/storybook/scaffold.tsx +62 -0
- package/src/styles/animations.css +141 -0
- package/src/styles/base.css +409 -0
- package/src/styles/colors.css +772 -0
- package/src/styles/file-tree.css +202 -0
- package/src/styles/index.css +37 -0
- package/src/styles/tailwind/colors.css +288 -0
- package/src/styles/tailwind/index.css +95 -0
- package/src/styles/tailwind/utilities.css +131 -0
- package/src/styles/theme.css +631 -0
- package/src/styles/tokens/colors.css +172 -0
- package/src/styles/tokens/index.css +2 -0
- package/src/styles/tokens/theme.css +510 -0
- package/src/styles/utilities.css +118 -0
- package/src/theme/color.ts +299 -0
- package/src/theme/context.tsx +381 -0
- package/src/theme/default-themes.ts +116 -0
- package/src/theme/index.ts +78 -0
- package/src/theme/loader.ts +112 -0
- package/src/theme/resolve.ts +540 -0
- package/src/theme/themes/amoled.json +49 -0
- package/src/theme/themes/aura.json +51 -0
- package/src/theme/themes/ayu.json +51 -0
- package/src/theme/themes/carbonfox.json +53 -0
- package/src/theme/themes/catppuccin-frappe.json +85 -0
- package/src/theme/themes/catppuccin-macchiato.json +85 -0
- package/src/theme/themes/catppuccin.json +45 -0
- package/src/theme/themes/cobalt2.json +87 -0
- package/src/theme/themes/cursor.json +91 -0
- package/src/theme/themes/dracula.json +49 -0
- package/src/theme/themes/everforest.json +89 -0
- package/src/theme/themes/flexoki.json +86 -0
- package/src/theme/themes/github.json +85 -0
- package/src/theme/themes/gruvbox.json +45 -0
- package/src/theme/themes/kanagawa.json +89 -0
- package/src/theme/themes/lucent-orng.json +87 -0
- package/src/theme/themes/material.json +87 -0
- package/src/theme/themes/matrix.json +113 -0
- package/src/theme/themes/mercury.json +86 -0
- package/src/theme/themes/monokai.json +49 -0
- package/src/theme/themes/nightowl.json +46 -0
- package/src/theme/themes/nord.json +46 -0
- package/src/theme/themes/oc-2.json +507 -0
- package/src/theme/themes/one-dark.json +89 -0
- package/src/theme/themes/onedarkpro.json +45 -0
- package/src/theme/themes/opencode.json +89 -0
- package/src/theme/themes/orng.json +87 -0
- package/src/theme/themes/osaka-jade.json +88 -0
- package/src/theme/themes/palenight.json +85 -0
- package/src/theme/themes/rosepine.json +85 -0
- package/src/theme/themes/shadesofpurple.json +51 -0
- package/src/theme/themes/solarized.json +49 -0
- package/src/theme/themes/synthwave84.json +87 -0
- package/src/theme/themes/tokyonight.json +47 -0
- package/src/theme/themes/vercel.json +90 -0
- package/src/theme/themes/vesper.json +51 -0
- package/src/theme/themes/zenburn.json +87 -0
- package/src/theme/types.ts +75 -0
- package/src/theme/v2/avatar.ts +48 -0
- package/src/theme/v2/default-primitives.ts +114 -0
- package/src/theme/v2/foreground.ts +61 -0
- package/src/theme/v2/mapping.ts +176 -0
- package/src/theme/v2/resolve.ts +153 -0
- package/src/typography/text-shimmer/text-shimmer.css +120 -0
- package/src/typography/text-shimmer/text-shimmer.tsx +63 -0
- package/src/typography/wordmark/wordmark.tsx +39 -0
- package/README.md +0 -5
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
createEffect,
|
|
4
|
+
createRoot,
|
|
5
|
+
createSignal,
|
|
6
|
+
getOwner,
|
|
7
|
+
onCleanup,
|
|
8
|
+
type Owner,
|
|
9
|
+
type ParentProps,
|
|
10
|
+
runWithOwner,
|
|
11
|
+
useContext,
|
|
12
|
+
type JSX,
|
|
13
|
+
startTransition,
|
|
14
|
+
For,
|
|
15
|
+
} from "solid-js"
|
|
16
|
+
import { Dialog as Kobalte } from "@kobalte/core/dialog"
|
|
17
|
+
import { makeEventListener } from "@solid-primitives/event-listener"
|
|
18
|
+
|
|
19
|
+
type DialogElement = () => JSX.Element
|
|
20
|
+
|
|
21
|
+
type Active = {
|
|
22
|
+
id: string
|
|
23
|
+
node: JSX.Element
|
|
24
|
+
dispose: () => void
|
|
25
|
+
owner: Owner
|
|
26
|
+
onClose?: () => void
|
|
27
|
+
setClosing: (closing: boolean) => void
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const Context = createContext<ReturnType<typeof init>>()
|
|
31
|
+
|
|
32
|
+
function init() {
|
|
33
|
+
const [stack, setStack] = createSignal<Active[]>([])
|
|
34
|
+
const timer = { current: undefined as ReturnType<typeof setTimeout> | undefined }
|
|
35
|
+
const lock = { value: false }
|
|
36
|
+
|
|
37
|
+
onCleanup(() => {
|
|
38
|
+
if (timer.current === undefined) return
|
|
39
|
+
clearTimeout(timer.current)
|
|
40
|
+
timer.current = undefined
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const close = (id?: string) => {
|
|
44
|
+
const items = stack()
|
|
45
|
+
const current = id ? items.find((item) => item.id === id) : items.at(-1)
|
|
46
|
+
if (!current || lock.value) return
|
|
47
|
+
lock.value = true
|
|
48
|
+
current.onClose?.()
|
|
49
|
+
current.setClosing(true)
|
|
50
|
+
|
|
51
|
+
const closed = current.id
|
|
52
|
+
if (timer.current !== undefined) {
|
|
53
|
+
clearTimeout(timer.current)
|
|
54
|
+
timer.current = undefined
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
timer.current = setTimeout(() => {
|
|
58
|
+
timer.current = undefined
|
|
59
|
+
current.dispose()
|
|
60
|
+
setStack((items) => items.filter((item) => item.id !== closed))
|
|
61
|
+
lock.value = false
|
|
62
|
+
}, 100)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
createEffect(() => {
|
|
66
|
+
if (stack().length === 0) return
|
|
67
|
+
|
|
68
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
69
|
+
if (event.key !== "Escape") return
|
|
70
|
+
close()
|
|
71
|
+
event.preventDefault()
|
|
72
|
+
event.stopPropagation()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
makeEventListener(window, "keydown", onKeyDown, { capture: true })
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const mount = (element: DialogElement, owner: Owner, onClose: (() => void) | undefined, layer: number) => {
|
|
79
|
+
const id = Math.random().toString(36).slice(2)
|
|
80
|
+
const zIndex = 50 + layer * 10
|
|
81
|
+
let dispose: (() => void) | undefined
|
|
82
|
+
let setClosing: ((closing: boolean) => void) | undefined
|
|
83
|
+
|
|
84
|
+
// Stacked dialogs render as sibling portals, so only the top layer may own the focus trap.
|
|
85
|
+
const node = runWithOwner(owner, () =>
|
|
86
|
+
createRoot((d: () => void) => {
|
|
87
|
+
dispose = d
|
|
88
|
+
const [closing, setClosingSignal] = createSignal(false)
|
|
89
|
+
setClosing = setClosingSignal
|
|
90
|
+
return (
|
|
91
|
+
<Kobalte
|
|
92
|
+
modal={stack().at(-1)?.id === id}
|
|
93
|
+
open={!closing()}
|
|
94
|
+
onOpenChange={(open: boolean) => {
|
|
95
|
+
if (open || stack().at(-1)?.id !== id) return
|
|
96
|
+
close(id)
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
<Kobalte.Portal>
|
|
100
|
+
<Kobalte.Overlay
|
|
101
|
+
data-component="dialog-overlay"
|
|
102
|
+
style={{ "z-index": String(zIndex) }}
|
|
103
|
+
onClick={() => close(id)}
|
|
104
|
+
/>
|
|
105
|
+
<div
|
|
106
|
+
data-dialog-layer={layer}
|
|
107
|
+
style={{
|
|
108
|
+
position: "fixed",
|
|
109
|
+
inset: "0",
|
|
110
|
+
"z-index": String(zIndex),
|
|
111
|
+
display: "flex",
|
|
112
|
+
"align-items": "center",
|
|
113
|
+
"justify-content": "center",
|
|
114
|
+
"pointer-events": "none",
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
{element()}
|
|
118
|
+
</div>
|
|
119
|
+
</Kobalte.Portal>
|
|
120
|
+
</Kobalte>
|
|
121
|
+
)
|
|
122
|
+
}),
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
if (!dispose || !setClosing) return
|
|
126
|
+
|
|
127
|
+
const active: Active = { id, node, dispose, owner, onClose, setClosing }
|
|
128
|
+
setStack((items) => [...items, active])
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const push = (element: DialogElement, owner: Owner, onClose?: () => void) => {
|
|
132
|
+
if (timer.current !== undefined) {
|
|
133
|
+
clearTimeout(timer.current)
|
|
134
|
+
timer.current = undefined
|
|
135
|
+
}
|
|
136
|
+
lock.value = false
|
|
137
|
+
mount(element, owner, onClose, stack().length)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const show = (element: DialogElement, owner: Owner, onClose?: () => void) => {
|
|
141
|
+
for (const item of stack()) item.dispose()
|
|
142
|
+
setStack([])
|
|
143
|
+
if (timer.current !== undefined) {
|
|
144
|
+
clearTimeout(timer.current)
|
|
145
|
+
timer.current = undefined
|
|
146
|
+
}
|
|
147
|
+
lock.value = false
|
|
148
|
+
mount(element, owner, onClose, 0)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
stack,
|
|
153
|
+
close,
|
|
154
|
+
show,
|
|
155
|
+
push,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function DialogProvider(props: ParentProps) {
|
|
160
|
+
const ctx = init()
|
|
161
|
+
return (
|
|
162
|
+
<Context.Provider value={ctx}>
|
|
163
|
+
{props.children}
|
|
164
|
+
<div data-component="dialog-stack">
|
|
165
|
+
<For each={ctx.stack()}>{(item) => item.node}</For>
|
|
166
|
+
</div>
|
|
167
|
+
</Context.Provider>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function useDialog() {
|
|
172
|
+
const ctx = useContext(Context)
|
|
173
|
+
const owner = getOwner()
|
|
174
|
+
|
|
175
|
+
if (!owner) {
|
|
176
|
+
throw new Error("useDialog must be used within a DialogProvider")
|
|
177
|
+
}
|
|
178
|
+
if (!ctx) {
|
|
179
|
+
throw new Error("useDialog must be used within a DialogProvider")
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return {
|
|
183
|
+
get active() {
|
|
184
|
+
return ctx.stack().at(-1)
|
|
185
|
+
},
|
|
186
|
+
show(element: DialogElement, onClose?: () => void) {
|
|
187
|
+
const base = ctx.stack().at(-1)?.owner ?? owner
|
|
188
|
+
return startTransition(() => ctx.show(element, base, onClose))
|
|
189
|
+
},
|
|
190
|
+
push(element: DialogElement, onClose?: () => void) {
|
|
191
|
+
const base = ctx.stack().at(-1)?.owner ?? owner
|
|
192
|
+
return startTransition(() => ctx.push(element, base, onClose))
|
|
193
|
+
},
|
|
194
|
+
close() {
|
|
195
|
+
ctx.close()
|
|
196
|
+
},
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ValidComponent } from "solid-js"
|
|
2
|
+
import { createSimpleContext } from "./helper"
|
|
3
|
+
|
|
4
|
+
const ctx = createSimpleContext<ValidComponent, { component: ValidComponent }>({
|
|
5
|
+
name: "FileComponent",
|
|
6
|
+
init: (props) => props.component,
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
export const FileComponentProvider = ctx.provider
|
|
10
|
+
export const useFileComponent = ctx.use
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createContext, createMemo, Show, useContext, type ParentProps, type Accessor } from "solid-js"
|
|
2
|
+
|
|
3
|
+
export function createSimpleContext<T, Props extends Record<string, any>>(
|
|
4
|
+
input: {
|
|
5
|
+
name: string
|
|
6
|
+
init: ((input: Props) => T) | (() => T)
|
|
7
|
+
} & (T extends { ready: unknown } ? { gate: boolean } : { gate?: boolean }),
|
|
8
|
+
) {
|
|
9
|
+
const ctx = createContext<T>()
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
provider: (props: ParentProps<Props>) => {
|
|
13
|
+
const init = input.init(props)
|
|
14
|
+
const gate = input.gate ?? true
|
|
15
|
+
|
|
16
|
+
if (!gate) {
|
|
17
|
+
return <ctx.Provider value={init}>{props.children}</ctx.Provider>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Access init.ready inside the memo to make it reactive for getter properties
|
|
21
|
+
const isReady = createMemo(() => {
|
|
22
|
+
// @ts-expect-error
|
|
23
|
+
const ready = init.ready as Accessor<boolean> | boolean | undefined
|
|
24
|
+
return ready === undefined || (typeof ready === "function" ? ready() : ready)
|
|
25
|
+
})
|
|
26
|
+
return (
|
|
27
|
+
<Show when={isReady()}>
|
|
28
|
+
<ctx.Provider value={init}>{props.children}</ctx.Provider>
|
|
29
|
+
</Show>
|
|
30
|
+
)
|
|
31
|
+
},
|
|
32
|
+
use() {
|
|
33
|
+
const value = useContext(ctx)
|
|
34
|
+
if (!value) throw new Error(`${input.name} context must be used within a context provider`)
|
|
35
|
+
return value
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createContext, useContext, type Accessor, type ParentProps } from "solid-js"
|
|
2
|
+
import { I18nProvider } from "@kobalte/core/i18n"
|
|
3
|
+
import { dict as en } from "../i18n/en"
|
|
4
|
+
import type { Key, LocaleKey, PluralCategory, PluralKey, PluralLookupKey } from "../i18n/en"
|
|
5
|
+
|
|
6
|
+
export type UiI18nKey = Key
|
|
7
|
+
export type UiI18nPluralKey = PluralKey
|
|
8
|
+
export type UiPluralCategory = PluralCategory
|
|
9
|
+
export type UiI18nPluralLookupKey = PluralLookupKey
|
|
10
|
+
export type UiI18nLocaleKey = LocaleKey
|
|
11
|
+
type UiTranslationKey<Value extends string> = Value extends UiI18nPluralLookupKey ? never : Value
|
|
12
|
+
|
|
13
|
+
export type UiI18nParams = Record<string, string | number | boolean>
|
|
14
|
+
export type UiTranslate = <Value extends string>(key: UiTranslationKey<Value>, params?: UiI18nParams) => string
|
|
15
|
+
|
|
16
|
+
export type UiI18n = {
|
|
17
|
+
locale: Accessor<string>
|
|
18
|
+
layoutLocale?: Accessor<string>
|
|
19
|
+
t: UiTranslate
|
|
20
|
+
plural: (key: UiI18nPluralKey, count: number, params?: UiI18nParams) => string
|
|
21
|
+
pluralForm?: (key: UiI18nPluralKey, category: UiPluralCategory, params?: UiI18nParams) => string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const rules = new Map<string, Intl.PluralRules>()
|
|
25
|
+
|
|
26
|
+
export function pluralCategory(locale: string, count: number): UiPluralCategory {
|
|
27
|
+
const cached = rules.get(locale)
|
|
28
|
+
if (cached) return cached.select(count)
|
|
29
|
+
const next = new Intl.PluralRules(locale)
|
|
30
|
+
if (rules.size >= 32) rules.delete(rules.keys().next().value!)
|
|
31
|
+
rules.set(locale, next)
|
|
32
|
+
return next.select(count)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function pluralKey(key: UiI18nPluralKey, category: UiPluralCategory) {
|
|
36
|
+
return `${key}.${category}` as UiI18nPluralLookupKey
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function resolveTemplate(text: string, params?: UiI18nParams) {
|
|
40
|
+
if (!params) return text
|
|
41
|
+
return text.replace(/{{\s*([^}]+?)\s*}}/g, (_, rawKey) => {
|
|
42
|
+
const key = String(rawKey)
|
|
43
|
+
const value = params[key]
|
|
44
|
+
return value === undefined ? "" : String(value)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const fallback: UiI18n = {
|
|
49
|
+
locale: () => "en",
|
|
50
|
+
t: (key, params) => {
|
|
51
|
+
const value = en[key as UiI18nKey] ?? String(key)
|
|
52
|
+
return resolveTemplate(value, params)
|
|
53
|
+
},
|
|
54
|
+
plural: (key, count, params) =>
|
|
55
|
+
fallback.pluralForm!(key, pluralCategory(fallback.locale(), count), { ...params, count }),
|
|
56
|
+
pluralForm: (key, category, params) => {
|
|
57
|
+
const values = en as Partial<Record<UiI18nLocaleKey, string>>
|
|
58
|
+
const value = values[pluralKey(key, category)] ?? values[`${key}.other`] ?? `${key}.other`
|
|
59
|
+
return resolveTemplate(value, params)
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const Context = createContext<UiI18n>(fallback)
|
|
64
|
+
|
|
65
|
+
function UiI18nProvider(props: ParentProps<{ value: UiI18n }>) {
|
|
66
|
+
return (
|
|
67
|
+
<I18nProvider locale={(props.value.layoutLocale ?? props.value.locale)()}>
|
|
68
|
+
<Context.Provider value={props.value}>{props.children}</Context.Provider>
|
|
69
|
+
</I18nProvider>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { UiI18nProvider as I18nProvider }
|
|
74
|
+
|
|
75
|
+
export function useI18n() {
|
|
76
|
+
return useContext(Context)
|
|
77
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Marked } from "marked"
|
|
2
|
+
|
|
3
|
+
export function createMarkdownBase() {
|
|
4
|
+
return new Marked({
|
|
5
|
+
renderer: {
|
|
6
|
+
link({ href, title, text }) {
|
|
7
|
+
const titleAttr = title ? ` title="${title}"` : ""
|
|
8
|
+
return `<a href="${href}"${titleAttr} class="external-link" target="_blank" rel="noopener noreferrer">${text}</a>`
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let smallParser: Marked | undefined
|
|
15
|
+
|
|
16
|
+
export function parseSmallMarkdown(text: string) {
|
|
17
|
+
// Any possible KaTeX delimiter stays on the worker, including escaped ones.
|
|
18
|
+
if (text.length > 1024 || text.includes("\\(") || text.includes("$$")) return
|
|
19
|
+
// Ordinary prose does not need the block/inline lexer's cold regular expressions.
|
|
20
|
+
// Keep every possible Markdown construct, autolink, and hard break on that lexer.
|
|
21
|
+
if (
|
|
22
|
+
/^[\p{L}\p{N} \t\r\n,.;:!?'"’“”()\-–—…$%]+$/u.test(text) &&
|
|
23
|
+
!/(?:^|[\r\n])(?:[ \t]|\d|[-])| {2}(?:\r\n?|\n)|www\./.test(text)
|
|
24
|
+
) {
|
|
25
|
+
return text
|
|
26
|
+
.replace(/\r\n?/g, "\n")
|
|
27
|
+
.replace(/^\n+|\n+$/g, "")
|
|
28
|
+
.split(/\n{2,}/)
|
|
29
|
+
.filter(Boolean)
|
|
30
|
+
.map((paragraph) => `<p>${paragraph.replace(/["']/g, (value) => (value === '"' ? """ : "'"))}</p>\n`)
|
|
31
|
+
.join("")
|
|
32
|
+
}
|
|
33
|
+
const parser = (smallParser ??= createMarkdownBase())
|
|
34
|
+
const paragraphs = text.replace(/\r\n?/g, "\n")
|
|
35
|
+
// Inline formatting in ordinary paragraphs does not need the block lexer.
|
|
36
|
+
// Any possible block opener, HTML, table, or reference definition stays on it.
|
|
37
|
+
if (
|
|
38
|
+
!/[<|]/.test(paragraphs) &&
|
|
39
|
+
!/^(?:[ \t>\d\[\-=]|#{1,6}(?:[ \t]|$)|[`~]{3}|[+*](?:[ \t]|$)|(?:[*_][ \t]*){3,}$)/m.test(paragraphs)
|
|
40
|
+
) {
|
|
41
|
+
return paragraphs
|
|
42
|
+
.replace(/^\n+|\n+$/g, "")
|
|
43
|
+
.split(/\n{2,}/)
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.map((paragraph) => `<p>${parser.parseInline(paragraph, { async: false })}</p>\n`)
|
|
46
|
+
.join("")
|
|
47
|
+
}
|
|
48
|
+
const tokens = parser.lexer(text)
|
|
49
|
+
let code = false
|
|
50
|
+
parser.walkTokens(tokens, (token) => {
|
|
51
|
+
if (token.type === "code") code = true
|
|
52
|
+
})
|
|
53
|
+
if (code) return
|
|
54
|
+
return parser.parser(tokens)
|
|
55
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import katex from "katex"
|
|
2
|
+
import type { MarkedExtension, Tokens } from "marked"
|
|
3
|
+
import markedShiki from "marked-shiki"
|
|
4
|
+
import { createMarkdownBase } from "./marked-base"
|
|
5
|
+
|
|
6
|
+
export function createMarkdownParser(highlight: (code: string, language: string) => string | Promise<string>) {
|
|
7
|
+
return createMarkdownBase().use(katexExtension, markedShiki({ highlight }))
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const inlineMathRegex = /^\\\(((?:\\.|[^\\\n])*?)\\\)/
|
|
11
|
+
const blockMathRegex = /^\$\$\n([\s\S]+?)\n\$\$(?:\n|$)/
|
|
12
|
+
|
|
13
|
+
const katexExtension: MarkedExtension = {
|
|
14
|
+
extensions: [
|
|
15
|
+
{
|
|
16
|
+
name: "inlineKatex",
|
|
17
|
+
level: "inline",
|
|
18
|
+
start(src) {
|
|
19
|
+
const index = src.indexOf("\\(")
|
|
20
|
+
if (index === -1) return
|
|
21
|
+
return index
|
|
22
|
+
},
|
|
23
|
+
tokenizer(src) {
|
|
24
|
+
const match = src.match(inlineMathRegex)
|
|
25
|
+
if (!match) return
|
|
26
|
+
return {
|
|
27
|
+
type: "inlineKatex",
|
|
28
|
+
raw: match[0],
|
|
29
|
+
text: match[1].trim(),
|
|
30
|
+
displayMode: false,
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
renderer: renderKatexToken,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "blockKatex",
|
|
37
|
+
level: "block",
|
|
38
|
+
tokenizer(src) {
|
|
39
|
+
const match = src.match(blockMathRegex)
|
|
40
|
+
if (!match) return
|
|
41
|
+
return {
|
|
42
|
+
type: "blockKatex",
|
|
43
|
+
raw: match[0],
|
|
44
|
+
text: match[1].trim(),
|
|
45
|
+
displayMode: true,
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
renderer: renderKatexToken,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function renderKatexToken(token: Tokens.Generic) {
|
|
54
|
+
return katex.renderToString(typeof token.text === "string" ? token.text : "", {
|
|
55
|
+
displayMode: token.displayMode === true,
|
|
56
|
+
throwOnError: false,
|
|
57
|
+
})
|
|
58
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { registerCustomTheme } from "@pierre/diffs"
|
|
2
|
+
import { OpenCodeTheme } from "./marked-theme"
|
|
3
|
+
|
|
4
|
+
let registered = false
|
|
5
|
+
|
|
6
|
+
export function registerOpenCodeTheme() {
|
|
7
|
+
if (registered) return
|
|
8
|
+
registered = true
|
|
9
|
+
registerCustomTheme("OpenCode", () => Promise.resolve(OpenCodeTheme))
|
|
10
|
+
}
|