@lobehub/ui 1.94.0 → 1.94.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/README.md CHANGED
@@ -108,30 +108,7 @@ $ pnpm start
108
108
 
109
109
  ## 🤝 Contributing
110
110
 
111
- <!-- CONTRIBUTION GROUP -->
112
-
113
- > 📊 Total: <kbd>**6**</kbd>
114
-
115
- <a href="https://github.com/canisminor1990" title="canisminor1990">
116
- <img src="https://avatars.githubusercontent.com/u/17870709?v=4" width="50" />
117
- </a>
118
- <a href="https://github.com/arvinxx" title="arvinxx">
119
- <img src="https://avatars.githubusercontent.com/u/28616219?v=4" width="50" />
120
- </a>
121
- <a href="https://github.com/apps/dependabot" title="dependabot[bot]">
122
- <img src="https://avatars.githubusercontent.com/in/29110?v=4" width="50" />
123
- </a>
124
- <a href="https://github.com/actions-user" title="actions-user">
125
- <img src="https://avatars.githubusercontent.com/u/65916846?v=4" width="50" />
126
- </a>
127
- <a href="https://github.com/Wxh16144" title="Wxh16144">
128
- <img src="https://avatars.githubusercontent.com/u/32004925?v=4" width="50" />
129
- </a>
130
- <a href="https://github.com/meganjohnson96" title="meganjohnson96">
131
- <img src="https://avatars.githubusercontent.com/u/136729222?v=4" width="50" />
132
- </a>
133
-
134
- <!-- CONTRIBUTION END -->
111
+ [![][contributors-contrib]][contributors-url]
135
112
 
136
113
  <div align="right">
137
114
 
@@ -166,6 +143,7 @@ This project is [MIT](./LICENSE) licensed.
166
143
  [ci-release-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ARelease%20CI
167
144
  [ci-test-shield]: https://github.com/lobehub/lobe-ui/workflows/Test%20CI/badge.svg
168
145
  [ci-test-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ATest%20CI
146
+ [contributors-contrib]: https://contrib.rocks/image?repo=lobehub/lobe-ui
169
147
  [contributors-shield]: https://img.shields.io/github/contributors/lobehub/lobe-ui.svg?style=flat
170
148
  [contributors-url]: https://github.com/lobehub/lobe-ui/graphs/contributors
171
149
  [forks-shield]: https://img.shields.io/github/forks/lobehub/lobe-ui.svg?style=flat
@@ -1,10 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { type HighlighterCoreOptions } from 'shikiji';
3
2
  import { DivProps } from "../../types";
4
3
  export interface SyntaxHighlighterProps extends DivProps {
5
4
  children: string;
6
5
  language: string;
7
- options?: HighlighterCoreOptions;
8
6
  }
9
7
  declare const SyntaxHighlighter: import("react").NamedExoticComponent<SyntaxHighlighterProps>;
10
8
  export default SyntaxHighlighter;
@@ -1,7 +1,6 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
1
  import { useThemeMode } from 'antd-style';
3
2
  import { Loader2 } from 'lucide-react';
4
- import { memo, useEffect } from 'react';
3
+ import { memo } from 'react';
5
4
  import { Center } from 'react-layout-kit';
6
5
  import Icon from "../../Icon";
7
6
  import { useHighlight } from "../../hooks/useHighlight";
@@ -12,7 +11,6 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
12
11
  var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
13
12
  var children = _ref.children,
14
13
  language = _ref.language,
15
- options = _ref.options,
16
14
  className = _ref.className,
17
15
  style = _ref.style;
18
16
  var _useStyles = useStyles(),
@@ -20,15 +18,9 @@ var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
20
18
  cx = _useStyles.cx;
21
19
  var _useThemeMode = useThemeMode(),
22
20
  isDarkMode = _useThemeMode.isDarkMode;
23
- var _useHighlight = useHighlight(function (s) {
24
- return [s.codeToHtml, !s.highlighter];
25
- }),
26
- _useHighlight2 = _slicedToArray(_useHighlight, 2),
27
- codeToHtml = _useHighlight2[0],
28
- isLoading = _useHighlight2[1];
29
- useEffect(function () {
30
- useHighlight.getState().initHighlighter(options);
31
- }, [options]);
21
+ var _useHighlight = useHighlight(children, language, isDarkMode),
22
+ isLoading = _useHighlight.isLoading,
23
+ data = _useHighlight.data;
32
24
  return /*#__PURE__*/_jsxs(_Fragment, {
33
25
  children: [isLoading ? /*#__PURE__*/_jsx("code", {
34
26
  className: className,
@@ -37,7 +29,7 @@ var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
37
29
  }) : /*#__PURE__*/_jsx("div", {
38
30
  className: cx(styles.shiki, className),
39
31
  dangerouslySetInnerHTML: {
40
- __html: codeToHtml(children, language, isDarkMode) || ''
32
+ __html: data
41
33
  },
42
34
  style: style
43
35
  }), isLoading && /*#__PURE__*/_jsxs(Center, {
@@ -1,4 +1,3 @@
1
- import 'katex/dist/katex.min.css';
2
1
  import { CSSProperties } from 'react';
3
2
  export interface MarkdownProps {
4
3
  /**
@@ -4,7 +4,6 @@ var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock"];
4
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
  import { Collapse, Divider, Image, Typography } from 'antd';
7
- import 'katex/dist/katex.min.css';
8
7
  import { memo } from 'react';
9
8
  import { ErrorBoundary } from 'react-error-boundary';
10
9
  import ReactMarkdown from 'react-markdown';
@@ -32,6 +32,10 @@ var ThemeProvider = /*#__PURE__*/memo(function (_ref) {
32
32
  path: 'css/index.css',
33
33
  pkg: '@lobehub/webfont-harmony-sans-sc',
34
34
  version: '1.0.0'
35
+ }), genCdnUrl({
36
+ path: 'dist/katex.min.css',
37
+ pkg: 'katex',
38
+ version: '0.16.8'
35
39
  })] : _ref$webfonts;
36
40
  useEffect(function () {
37
41
  setupStyled({
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export default ['abap', 'actionscript-3', 'ada', 'apache', 'apex', 'apl', 'applescript', 'ara', 'asm', 'astro', 'awk', 'ballerina', 'bat', 'beancount', 'berry', 'bibtex', 'bicep', 'blade', 'c', 'cadence', 'clarity', 'clojure', 'cmake', 'cobol', 'codeql', 'coffee', 'cpp', 'crystal', 'csharp', 'css', 'cue', 'cypher', 'd', 'dart', 'dax', 'diff', 'docker', 'dream-maker', 'elixir', 'elm', 'erb', 'erlang', 'fish', 'fsharp', 'gdresource', 'gdscript', 'gdshader', 'gherkin', 'git-commit', 'git-rebase', 'glimmer-js', 'glimmer-ts', 'glsl', 'gnuplot', 'go', 'graphql', 'groovy', 'hack', 'haml', 'handlebars', 'haskell', 'hcl', 'hjson', 'hlsl', 'html', 'http', 'imba', 'ini', 'java', 'javascript', 'jinja-html', 'jison', 'json', 'json5', 'jsonc', 'jsonl', 'jsonnet', 'jssm', 'jsx', 'julia', 'kotlin', 'kusto', 'latex', 'less', 'liquid', 'lisp', 'logo', 'lua', 'make', 'markdown', 'marko', 'matlab', 'mdc', 'mdx', 'mermaid', 'mojo', 'narrat', 'nextflow', 'nginx', 'nim', 'nix', 'objective-c', 'objective-cpp', 'ocaml', 'pascal', 'perl', 'php', 'plsql', 'postcss', 'powerquery', 'powershell', 'prisma', 'prolog', 'proto', 'pug', 'puppet', 'purescript', 'python', 'r', 'raku', 'razor', 'reg', 'rel', 'riscv', 'rst', 'ruby', 'rust', 'sas', 'sass', 'scala', 'scheme', 'scss', 'shaderlab', 'shellscript', 'shellsession', 'smalltalk', 'solidity', 'sparql', 'splunk', 'sql', 'ssh-config', 'stata', 'stylus', 'svelte', 'swift', 'system-verilog', 'tasl', 'tcl', 'tex', 'toml', 'tsx', 'turtle', 'twig', 'typescript', 'v', 'vb', 'verilog', 'vhdl', 'viml', 'vue', 'vue-html', 'vyper', 'wasm', 'wenyan', 'wgsl', 'wolfram', 'xml', 'xsl', 'yaml', 'zenscript', 'zig', 'bash', 'batch', 'be', 'c#', 'cdc', 'clj', 'cmd', 'console', 'cql', 'cs', 'dockerfile', 'erl', 'f#', 'fs', 'fsl', 'gjs', 'gts', 'hbs', 'hs', 'jade', 'js', 'kql', 'makefile', 'md', 'nar', 'nf', 'objc', 'perl6', 'properties', 'ps', 'ps1', 'py', 'ql', 'rb', 'rs', 'sh', 'shader', 'shell', 'spl', 'styl', 'ts', 'vim', 'vimscript', 'vy', 'yml', 'zsh', '文言'];
@@ -1,26 +1,2 @@
1
- import { type Highlighter, type HighlighterCoreOptions } from 'shikiji';
2
- export declare const languageMap: string[];
3
- /**
4
- * @title 代码高亮的存储对象
5
- */
6
- interface Store {
7
- /**
8
- * @title Convert code to HTML string
9
- * @param text - The code text
10
- * @param language - The language of the code
11
- * @param isDarkMode - Whether it's in dark mode or not
12
- * @returns HTML string
13
- */
14
- codeToHtml: (text: string, language: string, isDarkMode: boolean) => string;
15
- /**
16
- * @title Highlighter object
17
- */
18
- highlighter?: Highlighter;
19
- /**
20
- * @title Initialize the highlighter object
21
- * @returns Initialization promise object
22
- */
23
- initHighlighter: (options?: HighlighterCoreOptions) => Promise<void>;
24
- }
25
- export declare const useHighlight: import("zustand/traditional").UseBoundStoreWithEqualityFn<import("zustand/vanilla").StoreApi<Store>>;
26
- export {};
1
+ export declare const useHighlight: (text: string, language: string, isDarkMode: boolean) => import("swr/_internal").SWRResponse<string, any, any>;
2
+ export { default as languageMap } from './languageMap';
@@ -1,61 +1,12 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
- import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { bundledLanguages, getHighlighter } from 'shikiji';
4
- import { shallow } from 'zustand/shallow';
5
- import { createWithEqualityFn } from 'zustand/traditional';
1
+ import { codeToHtml } from 'shikiji';
2
+ import useSWR from 'swr';
6
3
  import { themeConfig } from "../Highlighter/theme";
7
- export var languageMap = Object.keys(bundledLanguages);
8
-
9
- /**
10
- * @title 代码高亮的存储对象
11
- */
12
-
13
- export var useHighlight = createWithEqualityFn(function (set, get) {
14
- return {
15
- codeToHtml: function codeToHtml(text, language, isDarkMode) {
16
- var _get = get(),
17
- highlighter = _get.highlighter;
18
- if (!highlighter) return '';
19
- try {
20
- return highlighter === null || highlighter === void 0 ? void 0 : highlighter.codeToHtml(text, {
21
- lang: language,
22
- theme: isDarkMode ? 'dark' : 'light'
23
- });
24
- } catch (_unused) {
25
- return text;
26
- }
27
- },
28
- highlighter: undefined,
29
- initHighlighter: function () {
30
- var _initHighlighter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
31
- var highlighter;
32
- return _regeneratorRuntime.wrap(function _callee$(_context) {
33
- while (1) switch (_context.prev = _context.next) {
34
- case 0:
35
- if (get().highlighter) {
36
- _context.next = 5;
37
- break;
38
- }
39
- _context.next = 3;
40
- return getHighlighter({
41
- langs: (options === null || options === void 0 ? void 0 : options.langs) || languageMap,
42
- themes: (options === null || options === void 0 ? void 0 : options.themes) || [themeConfig(true), themeConfig(false)]
43
- });
44
- case 3:
45
- highlighter = _context.sent;
46
- set({
47
- highlighter: highlighter
48
- });
49
- case 5:
50
- case "end":
51
- return _context.stop();
52
- }
53
- }, _callee);
54
- }));
55
- function initHighlighter(_x) {
56
- return _initHighlighter.apply(this, arguments);
57
- }
58
- return initHighlighter;
59
- }()
60
- };
61
- }, shallow);
4
+ export var useHighlight = function useHighlight(text, language, isDarkMode) {
5
+ return useSWR([text, language, String(isDarkMode)].join('-'), function () {
6
+ return codeToHtml(text, {
7
+ lang: language,
8
+ theme: themeConfig(isDarkMode)
9
+ });
10
+ });
11
+ };
12
+ export { default as languageMap } from "./languageMap";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.94.0",
3
+ "version": "1.94.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -88,7 +88,6 @@
88
88
  "emoji-regex": "^10",
89
89
  "fast-deep-equal": "^3",
90
90
  "immer": "^10",
91
- "katex": "^0.16",
92
91
  "leva": "^0",
93
92
  "lodash-es": "^4",
94
93
  "lucide-react": "latest",
@@ -107,6 +106,7 @@
107
106
  "remark-math": "^5",
108
107
  "shikiji": "^0",
109
108
  "styled-components": "^6",
109
+ "swr": "^2",
110
110
  "three": "^0.150",
111
111
  "ts-md5": "^1",
112
112
  "use-merge-value": "^1",