@mujian/js-sdk 0.0.6-beta.29 → 0.0.6-beta.30
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/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMount, useRequest, useUpdateEffect } from "ahooks";
|
|
2
2
|
import react, { createContext, forwardRef, useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import css_tools from "@adobe/css-tools";
|
|
5
5
|
import dompurify from "dompurify";
|
|
6
6
|
import showdown from "showdown";
|
|
@@ -636,6 +636,43 @@ class MujianSdk {
|
|
|
636
636
|
}
|
|
637
637
|
};
|
|
638
638
|
}
|
|
639
|
+
const styleSheet = `
|
|
640
|
+
@keyframes spin {
|
|
641
|
+
0% { transform: rotate(0deg); }
|
|
642
|
+
100% { transform: rotate(360deg); }
|
|
643
|
+
}
|
|
644
|
+
`;
|
|
645
|
+
const spinnerStyle = {
|
|
646
|
+
width: 48,
|
|
647
|
+
height: 48,
|
|
648
|
+
animation: 'spin 1s linear infinite'
|
|
649
|
+
};
|
|
650
|
+
const MujianSpinner = ({ className, style })=>/*#__PURE__*/ jsxs(Fragment, {
|
|
651
|
+
children: [
|
|
652
|
+
/*#__PURE__*/ jsx("style", {
|
|
653
|
+
children: styleSheet
|
|
654
|
+
}),
|
|
655
|
+
/*#__PURE__*/ jsx("svg", {
|
|
656
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
657
|
+
width: "24",
|
|
658
|
+
height: "24",
|
|
659
|
+
viewBox: "0 0 24 24",
|
|
660
|
+
fill: "none",
|
|
661
|
+
stroke: "currentColor",
|
|
662
|
+
strokeWidth: "2",
|
|
663
|
+
strokeLinecap: "round",
|
|
664
|
+
strokeLinejoin: "round",
|
|
665
|
+
className: className,
|
|
666
|
+
style: {
|
|
667
|
+
...spinnerStyle,
|
|
668
|
+
...style
|
|
669
|
+
},
|
|
670
|
+
children: /*#__PURE__*/ jsx("path", {
|
|
671
|
+
d: "M21 12a9 9 0 1 1-6.219-8.56"
|
|
672
|
+
})
|
|
673
|
+
})
|
|
674
|
+
]
|
|
675
|
+
});
|
|
639
676
|
const MujianContext = /*#__PURE__*/ createContext(null);
|
|
640
677
|
const MujianProvider = ({ children, loadingComponent })=>{
|
|
641
678
|
const [mujian, setMujian] = useState(null);
|
|
@@ -648,7 +685,20 @@ const MujianProvider = ({ children, loadingComponent })=>{
|
|
|
648
685
|
}, []);
|
|
649
686
|
return /*#__PURE__*/ jsx(MujianContext.Provider, {
|
|
650
687
|
value: mujian,
|
|
651
|
-
children: mujian ? children : loadingComponent ??
|
|
688
|
+
children: mujian ? children : loadingComponent ?? /*#__PURE__*/ jsx("div", {
|
|
689
|
+
style: {
|
|
690
|
+
height: '100%',
|
|
691
|
+
width: '100%',
|
|
692
|
+
display: 'flex',
|
|
693
|
+
justifyContent: 'center',
|
|
694
|
+
alignItems: 'center'
|
|
695
|
+
},
|
|
696
|
+
children: /*#__PURE__*/ jsx(MujianSpinner, {
|
|
697
|
+
style: {
|
|
698
|
+
color: '#EC4342'
|
|
699
|
+
}
|
|
700
|
+
})
|
|
701
|
+
})
|
|
652
702
|
});
|
|
653
703
|
};
|
|
654
704
|
const useMujian = ()=>{
|
|
@@ -1062,4 +1112,4 @@ const useChat = ({ body, onError, onFinish })=>{
|
|
|
1062
1112
|
deleteMessage
|
|
1063
1113
|
};
|
|
1064
1114
|
};
|
|
1065
|
-
export { MdRenderer, MujianProvider, Thread, useChat, useMujian };
|
|
1115
|
+
export { MdRenderer, MujianProvider, MujianSpinner, Thread, useChat, useMujian };
|