@lobehub/ui 1.153.13 → 1.153.15

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.
@@ -1,7 +1,3 @@
1
1
  export declare const FALLBACK_LANG = "txt";
2
- export declare const useHighlight: (text: string, lang: string, isDarkMode: boolean) => import("swr/dist/_internal").SWRResponse<string, any, {
3
- refreshWhenOffline: false;
4
- revalidateOnFocus: false;
5
- revalidateOnReconnect: false;
6
- }>;
2
+ export declare const useHighlight: (text: string, lang: string, isDarkMode: boolean) => import("swr/dist/_internal").SWRResponse<string, any, any>;
7
3
  export { default as languageMap } from './languageMap';
@@ -5,6 +5,7 @@ import { codeToHtml } from 'shiki';
5
5
  import useSWR from 'swr';
6
6
  import { Md5 } from 'ts-md5';
7
7
  import { themeConfig } from "../Highlighter/theme";
8
+ import languageMap from "./languageMap";
8
9
  export var FALLBACK_LANG = 'txt';
9
10
  export var useHighlight = function useHighlight(text, lang, isDarkMode) {
10
11
  return useSWR(Md5.hashStr([lang.toLowerCase(), isDarkMode ? 'd' : 'l', text].join('-')), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -15,7 +16,7 @@ export var useHighlight = function useHighlight(text, lang, isDarkMode) {
15
16
  _context.prev = 0;
16
17
  language = lang.toLowerCase();
17
18
  return _context.abrupt("return", codeToHtml(text, {
18
- lang: language,
19
+ lang: languageMap.includes(language) ? language : FALLBACK_LANG,
19
20
  theme: themeConfig(isDarkMode),
20
21
  transformers: [transformerNotationDiff(), transformerNotationHighlight(), transformerNotationWordHighlight(), transformerNotationFocus(), transformerNotationErrorLevel()]
21
22
  }));
@@ -28,10 +29,6 @@ export var useHighlight = function useHighlight(text, lang, isDarkMode) {
28
29
  return _context.stop();
29
30
  }
30
31
  }, _callee, null, [[0, 5]]);
31
- })), {
32
- refreshWhenOffline: false,
33
- revalidateOnFocus: false,
34
- revalidateOnReconnect: false
35
- });
32
+ })));
36
33
  };
37
34
  export { default as languageMap } from "./languageMap";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.153.13",
3
+ "version": "1.153.15",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",