@opentiny/tiny-robot 0.3.0-alpha.2 → 0.3.0-alpha.21

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/index.js CHANGED
@@ -1,84 +1,223 @@
1
- import { Bubble as s, BubbleList as t, BubbleProvider as n } from "./bubble/index.js";
2
- import { BubbleChainMessageRenderer as E, BubbleMarkdownMessageRenderer as j, BubbleMessageClassRenderer as q } from "./bubble/index.js";
3
- import i from "./container/index.js";
4
- import a from "./conversations/index.js";
5
- import m from "./dropdown-menu/index.js";
6
- import p from "./feedback/index.js";
7
- import u from "./history/index.js";
8
- import l from "./icon-button/index.js";
9
- import { Prompt as T, Prompts as b } from "./prompts/index.js";
10
- import f from "./question/index.js";
11
- import g from "./sender/index.js";
12
- import c from "./welcome/index.js";
13
- import d from "./suggestion/index.js";
14
- import B from "./suggestion-popover/index.js";
15
- import P, { SuggestionPillButton as S } from "./suggestion-pills/index.js";
16
- const v = [
17
- s,
18
- t,
19
- n,
20
- i,
21
- a,
22
- m,
23
- p,
24
- u,
25
- l,
26
- T,
1
+ import z from "./attachments/index.js";
2
+ import { Bubble as x, BubbleList as E, BubbleProvider as S } from "./bubble/index.js";
3
+ import { BubbleContentClassRenderer as ve, BubbleMarkdownContentRenderer as fe } from "./bubble/index.js";
4
+ import P from "./container/index.js";
5
+ import b from "./conversations/index.js";
6
+ import L from "./drag-overlay/index.js";
7
+ import C from "./dropdown-menu/index.js";
8
+ import B from "./feedback/index.js";
9
+ import y from "./history/index.js";
10
+ import O from "./icon-button/index.js";
11
+ import { Prompt as j, Prompts as A } from "./prompts/index.js";
12
+ import H from "./sender/index.js";
13
+ import M, { SuggestionPillButton as w } from "./suggestion-pills/index.js";
14
+ import R from "./suggestion-popover/index.js";
15
+ import k from "./theme-provider/index.js";
16
+ import { useTheme as ge } from "./theme-provider/index.js";
17
+ import W from "./welcome/index.js";
18
+ import $ from "./mcp-server-picker/index.js";
19
+ import I from "./mcp-add-form/index.js";
20
+ var d = /* @__PURE__ */ ((e) => (e.FileTypeNotAllowed = "file-type-not-allowed", e.FileSizeExceeded = "file-size-exceeded", e.FileCountExceeded = "file-count-exceeded", e))(d || {});
21
+ function N(e, r) {
22
+ if (!r) return !0;
23
+ const t = r.split(",").map((o) => o.trim());
24
+ return t.includes("*") ? !0 : t.some((o) => {
25
+ if (o.startsWith("."))
26
+ return e.name.toLowerCase().endsWith(o.toLowerCase());
27
+ if (o.includes("/*")) {
28
+ const a = o.split("/")[0];
29
+ return e.type.startsWith(a + "/");
30
+ } else
31
+ return e.type === o;
32
+ });
33
+ }
34
+ function _(e, r) {
35
+ return e.size <= r;
36
+ }
37
+ function q(e, r) {
38
+ return e.length <= r;
39
+ }
40
+ function G(e, r) {
41
+ const { accept: t, multiple: o, maxSize: a, maxFiles: l } = r, n = [], s = [];
42
+ if (!q(e, l))
43
+ return {
44
+ acceptedFiles: n,
45
+ rejectedFiles: Array.from(e),
46
+ rejectionReason: {
47
+ code: d.FileCountExceeded,
48
+ message: `文件数量不能超过 ${l} 个`
49
+ }
50
+ };
51
+ if (e.forEach((i) => {
52
+ N(i, t) && _(i, a) ? n.push(i) : s.push(i);
53
+ }), !o && n.length > 1)
54
+ return {
55
+ acceptedFiles: [],
56
+ rejectedFiles: n,
57
+ rejectionReason: {
58
+ code: d.FileCountExceeded,
59
+ message: "只允许上传一个文件"
60
+ }
61
+ };
62
+ if (s.length > 0) {
63
+ const i = s.some((c) => !_(c, a)), p = i ? d.FileSizeExceeded : d.FileTypeNotAllowed, m = i ? `文件大小不能超过 ${a / 1024 / 1024}MB` : `文件类型不匹配 (accept: ${t})`;
64
+ return {
65
+ acceptedFiles: n,
66
+ rejectedFiles: s,
67
+ rejectionReason: { code: p, message: m }
68
+ };
69
+ }
70
+ return { acceptedFiles: n, rejectedFiles: s, rejectionReason: null };
71
+ }
72
+ function g(e) {
73
+ return {
74
+ accept: e.accept || "*",
75
+ multiple: e.multiple ?? !0,
76
+ maxSize: e.maxSize || 1024 * 1024 * 10,
77
+ maxFiles: e.maxFiles || 3,
78
+ onDrop: e.onDrop,
79
+ onError: e.onError,
80
+ disabled: e.disabled || !1
81
+ };
82
+ }
83
+ const pe = {
84
+ /**
85
+ * 挂载指令
86
+ * @param el 元素
87
+ * @param binding 绑定
88
+ */
89
+ mounted(e, r) {
90
+ let t = 0;
91
+ const { disabled: o, onDraggingChange: a } = r.value;
92
+ e.__vDropzoneOptions__ = g(r.value);
93
+ const l = {
94
+ /**
95
+ * 拖拽进入
96
+ */
97
+ handleDragEnter: () => {
98
+ o || (t++, t === 1 && a(!0, e));
99
+ },
100
+ /**
101
+ * 拖拽覆盖
102
+ * @param e 事件
103
+ */
104
+ handleDragOver: (n) => {
105
+ o || n.preventDefault();
106
+ },
107
+ /**
108
+ * 拖拽离开
109
+ */
110
+ handleDragLeave: () => {
111
+ o || (t--, t === 0 && a(!1, null));
112
+ },
113
+ /**
114
+ * 拖拽放下
115
+ * @param e 事件
116
+ */
117
+ handleDrop: (n) => {
118
+ var u;
119
+ if (o) return;
120
+ n.preventDefault(), t = 0, a(!1, null);
121
+ const s = (u = n.dataTransfer) == null ? void 0 : u.files, { onDrop: i, onError: p, accept: m, multiple: c, maxSize: D, maxFiles: h } = e.__vDropzoneOptions__;
122
+ if (s && s.length > 0) {
123
+ const T = Array.from(s), { acceptedFiles: v, rejectedFiles: F, rejectionReason: f } = G(T, {
124
+ accept: m,
125
+ multiple: c,
126
+ maxSize: D,
127
+ maxFiles: h
128
+ });
129
+ f && p({ files: F, ...f }), v.length > 0 && i(v);
130
+ }
131
+ }
132
+ };
133
+ e.__vDropzoneHandlers__ = l, e.addEventListener("dragenter", l.handleDragEnter), e.addEventListener("dragover", l.handleDragOver), e.addEventListener("dragleave", l.handleDragLeave), e.addEventListener("drop", l.handleDrop);
134
+ },
135
+ updated(e, r) {
136
+ e.__vDropzoneOptions__ && (e.__vDropzoneOptions__ = g(r.value));
137
+ },
138
+ /**
139
+ * 卸载指令
140
+ * @param el 元素
141
+ */
142
+ unmounted(e) {
143
+ e.__vDropzoneHandlers__ && (e.removeEventListener("dragenter", e.__vDropzoneHandlers__.handleDragEnter), e.removeEventListener("dragover", e.__vDropzoneHandlers__.handleDragOver), e.removeEventListener("dragleave", e.__vDropzoneHandlers__.handleDragLeave), e.removeEventListener("drop", e.__vDropzoneHandlers__.handleDrop), delete e.__vDropzoneHandlers__), delete e.__vDropzoneOptions__;
144
+ }
145
+ }, J = [
146
+ z,
147
+ x,
148
+ E,
149
+ S,
150
+ P,
27
151
  b,
28
- f,
29
- g,
30
- c,
31
- d,
152
+ L,
153
+ C,
32
154
  B,
33
- P,
34
- S
35
- ], L = {
36
- install(o) {
37
- v.forEach((r) => {
38
- const e = r.name.replace(/^Tiny/, "").replace(/^Tr/, "");
39
- o.component(`Tr${e}`, r);
155
+ y,
156
+ O,
157
+ j,
158
+ A,
159
+ H,
160
+ M,
161
+ w,
162
+ R,
163
+ k,
164
+ W,
165
+ $,
166
+ I
167
+ ], me = {
168
+ install(e) {
169
+ J.forEach((r) => {
170
+ const t = r.name.replace(/^Tiny/, "").replace(/^Tr/, "");
171
+ e.component(`Tr${t}`, r);
40
172
  });
41
173
  }
42
174
  };
43
175
  export {
44
- s as Bubble,
45
- E as BubbleChainMessageRenderer,
46
- t as BubbleList,
47
- j as BubbleMarkdownMessageRenderer,
48
- q as BubbleMessageClassRenderer,
49
- n as BubbleProvider,
50
- i as Container,
51
- a as Conversations,
52
- m as DropdownMenu,
53
- p as Feedback,
54
- u as History,
55
- l as IconButton,
56
- T as Prompt,
57
- b as Prompts,
58
- f as Question,
59
- g as Sender,
60
- d as Suggestion,
61
- S as SuggestionPillButton,
62
- P as SuggestionPills,
63
- B as SuggestionPopover,
64
- s as TrBubble,
65
- t as TrBubbleList,
66
- n as TrBubbleProvider,
67
- i as TrContainer,
68
- a as TrConversations,
69
- m as TrDropdownMenu,
70
- p as TrFeedback,
71
- u as TrHistory,
72
- l as TrIconButton,
73
- T as TrPrompt,
74
- b as TrPrompts,
75
- f as TrQuestion,
76
- g as TrSender,
77
- d as TrSuggestion,
78
- S as TrSuggestionPillButton,
79
- P as TrSuggestionPills,
80
- B as TrSuggestionPopover,
81
- c as TrWelcome,
82
- c as Welcome,
83
- L as default
176
+ z as Attachments,
177
+ x as Bubble,
178
+ ve as BubbleContentClassRenderer,
179
+ E as BubbleList,
180
+ fe as BubbleMarkdownContentRenderer,
181
+ S as BubbleProvider,
182
+ P as Container,
183
+ b as Conversations,
184
+ L as DragOverlay,
185
+ C as DropdownMenu,
186
+ B as Feedback,
187
+ y as History,
188
+ O as IconButton,
189
+ I as McpAddForm,
190
+ $ as McpServerPicker,
191
+ j as Prompt,
192
+ A as Prompts,
193
+ H as Sender,
194
+ w as SuggestionPillButton,
195
+ M as SuggestionPills,
196
+ R as SuggestionPopover,
197
+ k as ThemeProvider,
198
+ z as TrAttachments,
199
+ x as TrBubble,
200
+ E as TrBubbleList,
201
+ S as TrBubbleProvider,
202
+ P as TrContainer,
203
+ b as TrConversations,
204
+ L as TrDragOverlay,
205
+ C as TrDropdownMenu,
206
+ B as TrFeedback,
207
+ y as TrHistory,
208
+ O as TrIconButton,
209
+ I as TrMcpAddForm,
210
+ $ as TrMcpServerPicker,
211
+ j as TrPrompt,
212
+ A as TrPrompts,
213
+ H as TrSender,
214
+ w as TrSuggestionPillButton,
215
+ M as TrSuggestionPills,
216
+ R as TrSuggestionPopover,
217
+ k as TrThemeProvider,
218
+ W as TrWelcome,
219
+ W as Welcome,
220
+ me as default,
221
+ ge as useTheme,
222
+ pe as vDropzone
84
223
  };