@linker-design-plus/chat-next 1.0.1 → 1.0.2

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.
Files changed (28) hide show
  1. package/dist/eventSource.js +1 -0
  2. package/dist/eventSource.mjs +65 -0
  3. package/dist/index.d.ts +8 -2
  4. package/dist/index.js +59 -1
  5. package/dist/index.mjs +52803 -57
  6. package/dist/src/component/ChatActionbar/chat-actionbar.vue.d.ts +15 -0
  7. package/dist/src/component/ChatAttachments/chat-attachments.vue.d.ts +29 -0
  8. package/dist/src/component/ChatItem/chat-item.vue.d.ts +30 -0
  9. package/dist/src/component/ChatLoading/chat-loading.vue.d.ts +9 -0
  10. package/dist/src/component/ChatMarkdown/chat-markdown.vue.d.ts +9 -0
  11. package/dist/src/component/ChatSender/chat-sender-editor.vue.d.ts +15 -0
  12. package/dist/src/component/ChatSender/chat-sender-select.vue.d.ts +16 -0
  13. package/dist/src/component/ChatSender/chat-sender.vue.d.ts +51 -0
  14. package/dist/src/component/ChatThinking/chat-thinking.vue.d.ts +21 -0
  15. package/dist/src/hooks/useCopy.d.ts +5 -0
  16. package/dist/src/hooks/useEventSource.d.ts +53 -0
  17. package/dist/src/typing/chat-next/i-chat-actionbar.d.ts +1 -0
  18. package/dist/src/typing/chat-next/i-chat-attachment.d.ts +12 -0
  19. package/dist/src/typing/chat-next/i-chat-item.d.ts +11 -0
  20. package/dist/src/typing/chat-next/i-chat-loading.d.ts +1 -0
  21. package/dist/src/typing/chat-next/i-chat-sender.d.ts +15 -0
  22. package/dist/src/typing/chat-next/i-chat-thinking.d.ts +15 -0
  23. package/dist/src/typing/index.d.ts +6 -0
  24. package/dist/src/utils/file.d.ts +7 -0
  25. package/dist/style.css +1 -1
  26. package/package.json +15 -1
  27. package/dist/src/component/chat-item.vue.d.ts +0 -20
  28. package/dist/src/component/chat-sender.vue.d.ts +0 -8
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@microsoft/fetch-event-source"),u=require("vue"),o=r=>{try{const t=JSON.parse(r);return typeof t=="object"&&t!==null&&(Array.isArray(t)||t.constructor===Object)}catch{return!1}},v=()=>{const r=u.ref(null),t=u.ref(!1);return{startEventSource:async e=>{t.value=!0,r.value=new AbortController;try{await s.fetchEventSource(e.url,{method:e.method||"POST",headers:{"Content-Type":"application/json",accept:"*/*",...e.headers},body:e.body?JSON.stringify(e.body):void 0,openWhenHidden:!0,signal:r.value.signal,async onmessage(a){var c;try{if(!o(a.data))return;const l=JSON.parse(a.data);(c=e.onMessage)==null||c.call(e,{event:a.event,data:l})}catch(n){console.error("解析消息失败:",n)}},onclose(){var a;(a=e.onClose)==null||a.call(e)},onerror(a){var c,n;throw(c=e.onError)==null||c.call(e,a),(n=r.value)==null||n.abort(),a}})}finally{t.value=!1}},stopEventSource:()=>{r.value&&(r.value.abort(),r.value=null)},isConnecting:t,controller:r}};exports.useEventSource=v;
@@ -0,0 +1,65 @@
1
+ import { fetchEventSource as o } from "@microsoft/fetch-event-source";
2
+ import { ref as l } from "vue";
3
+ const s = (r) => {
4
+ try {
5
+ const a = JSON.parse(r);
6
+ return typeof a == "object" && a !== null && (Array.isArray(a) || a.constructor === Object);
7
+ } catch {
8
+ return !1;
9
+ }
10
+ }, S = () => {
11
+ const r = l(null), a = l(!1);
12
+ return {
13
+ startEventSource: async (e) => {
14
+ a.value = !0, r.value = new AbortController();
15
+ try {
16
+ await o(e.url, {
17
+ method: e.method || "POST",
18
+ headers: {
19
+ "Content-Type": "application/json",
20
+ // 'Accept-Language': localStorage.getItem('language') === 'en' ? 'en' : 'zh-CN',
21
+ // token: JSON.parse(localStorage.getItem('loginState') || '{}')?.token || '',
22
+ // tenant: localStorage.getItem('currentTanantID') || '',
23
+ accept: "*/*",
24
+ ...e.headers
25
+ },
26
+ body: e.body ? JSON.stringify(e.body) : void 0,
27
+ openWhenHidden: !0,
28
+ signal: r.value.signal,
29
+ async onmessage(t) {
30
+ var n;
31
+ try {
32
+ if (!s(t.data))
33
+ return;
34
+ const u = JSON.parse(t.data);
35
+ (n = e.onMessage) == null || n.call(e, {
36
+ event: t.event,
37
+ data: u
38
+ });
39
+ } catch (c) {
40
+ console.error("解析消息失败:", c);
41
+ }
42
+ },
43
+ onclose() {
44
+ var t;
45
+ (t = e.onClose) == null || t.call(e);
46
+ },
47
+ onerror(t) {
48
+ var n, c;
49
+ throw (n = e.onError) == null || n.call(e, t), (c = r.value) == null || c.abort(), t;
50
+ }
51
+ });
52
+ } finally {
53
+ a.value = !1;
54
+ }
55
+ },
56
+ stopEventSource: () => {
57
+ r.value && (r.value.abort(), r.value = null);
58
+ },
59
+ isConnecting: a,
60
+ controller: r
61
+ };
62
+ };
63
+ export {
64
+ S as useEventSource
65
+ };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,8 @@
1
- export { default as HChatItem } from './src/component/chat-item.vue';
2
- export { default as HChatSender } from './src/component/chat-sender.vue';
1
+ export { default as HChatItem } from './src/component/ChatItem/chat-item.vue';
2
+ export { default as HChatSender } from './src/component/ChatSender/chat-sender.vue';
3
+ export { default as HChatMarkdown } from './src/component/ChatMarkdown/chat-markdown.vue';
4
+ export { default as HChatActionbar } from './src/component/ChatActionbar/chat-actionbar.vue';
5
+ export { default as HChatLoading } from './src/component/ChatLoading/chat-loading.vue';
6
+ export { default as HChatThinking } from './src/component/ChatThinking/chat-thinking.vue';
7
+ export { default as HChatAttachments } from './src/component/ChatAttachments/chat-attachments.vue';
8
+ export { default as HChatSenderSelect } from './src/component/ChatSender/chat-sender-select.vue';