@opentiny/tiny-robot 0.5.2-beta.0 → 1.0.0-beta.0

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.d.ts CHANGED
@@ -88,6 +88,7 @@ open: boolean;
88
88
  placeholder: string;
89
89
  placement: Placement;
90
90
  emptyText: string;
91
+ appendTo: string | HTMLElement;
91
92
  offset: number;
92
93
  searchable: boolean;
93
94
  searchPlaceholder: string;
@@ -277,21 +278,7 @@ setContent: (content: string) => void;
277
278
  getContent: () => string;
278
279
  editor: Editor | undefined;
279
280
  } & {} & ComponentCustomProperties & {} & {
280
- $slots: {
281
- header?(_: {}): any;
282
- header?(_: {}): any;
283
- prefix?(_: {}): any;
284
- prefix?(_: {}): any;
285
- content?(_: {
286
- editor: Editor | undefined;
287
- }): any;
288
- content?(_: {
289
- editor: Ref<Editor | undefined, Editor | undefined>;
290
- }): any;
291
- 'actions-inline'?(_: {}): any;
292
- footer?(_: {}): any;
293
- 'footer-right'?(_: {}): any;
294
- };
281
+ $slots: Readonly<SenderSlots> & SenderSlots;
295
282
  }) | null;
296
283
  voiceRef: ({
297
284
  $: ComponentInternalInstance;
@@ -1114,12 +1101,52 @@ declare function __VLS_template_12(): {
1114
1101
  header?(_: {}): any;
1115
1102
  prefix?(_: {}): any;
1116
1103
  content?(_: {
1117
- editor: Ref<Editor | undefined, Editor | undefined>;
1104
+ editor: unknown;
1105
+ }): any;
1106
+ actions?(_: {
1107
+ editor: Editor_2 | undefined;
1108
+ focus: () => void;
1109
+ blur: () => void;
1110
+ insert: (content: string) => void;
1111
+ append: (content: string) => void;
1112
+ replace: (content: string) => void;
1113
+ disabled: boolean;
1114
+ loading: boolean;
1115
+ hasContent: boolean;
1116
+ }): any;
1117
+ 'footer-left'?(_: {
1118
+ editor: Editor_2 | undefined;
1119
+ focus: () => void;
1120
+ blur: () => void;
1121
+ insert: (content: string) => void;
1122
+ append: (content: string) => void;
1123
+ replace: (content: string) => void;
1124
+ disabled: boolean;
1125
+ loading: boolean;
1126
+ hasContent: boolean;
1127
+ }): any;
1128
+ footer?(_: {
1129
+ editor: Editor_2 | undefined;
1130
+ focus: () => void;
1131
+ blur: () => void;
1132
+ insert: (content: string) => void;
1133
+ append: (content: string) => void;
1134
+ replace: (content: string) => void;
1135
+ disabled: boolean;
1136
+ loading: boolean;
1137
+ hasContent: boolean;
1138
+ }): any;
1139
+ 'footer-right'?(_: {
1140
+ editor: Editor_2 | undefined;
1141
+ focus: () => void;
1142
+ blur: () => void;
1143
+ insert: (content: string) => void;
1144
+ append: (content: string) => void;
1145
+ replace: (content: string) => void;
1146
+ disabled: boolean;
1147
+ loading: boolean;
1148
+ hasContent: boolean;
1118
1149
  }): any;
1119
- actions?(_: {}): any;
1120
- 'footer-left'?(_: {}): any;
1121
- footer?(_: {}): any;
1122
- 'footer-right'?(_: {}): any;
1123
1150
  };
1124
1151
  refs: {
1125
1152
  senderRef: ({
@@ -1245,21 +1272,7 @@ declare function __VLS_template_12(): {
1245
1272
  getContent: () => string;
1246
1273
  editor: Editor | undefined;
1247
1274
  } & {} & ComponentCustomProperties & {} & {
1248
- $slots: {
1249
- header?(_: {}): any;
1250
- header?(_: {}): any;
1251
- prefix?(_: {}): any;
1252
- prefix?(_: {}): any;
1253
- content?(_: {
1254
- editor: Editor | undefined;
1255
- }): any;
1256
- content?(_: {
1257
- editor: Ref<Editor | undefined, Editor | undefined>;
1258
- }): any;
1259
- 'actions-inline'?(_: {}): any;
1260
- footer?(_: {}): any;
1261
- 'footer-right'?(_: {}): any;
1262
- };
1275
+ $slots: Readonly<SenderSlots> & SenderSlots;
1263
1276
  }) | null;
1264
1277
  voiceRef: ({
1265
1278
  $: ComponentInternalInstance;
@@ -2656,10 +2669,6 @@ declare const _default_15: typeof _default_48 & {
2656
2669
  export { _default_15 as TrWelcome }
2657
2670
  export { _default_15 as Welcome }
2658
2671
 
2659
- /**
2660
- * @deprecated Use ExtensionManager and its Card/CardGrid namespace components instead.
2661
- * This entry point remains available for compatibility and will be removed in a future major release.
2662
- */
2663
2672
  declare const _default_16: typeof _default_49 & {
2664
2673
  install: typeof install_16;
2665
2674
  };
@@ -2691,7 +2700,7 @@ export { _default_20 as ClearButton }
2691
2700
  export { _default_20 as TrClearButton }
2692
2701
 
2693
2702
  declare const _default_21: DefineComponent<UploadButtonProps, {
2694
- open: (localOptions?: Partial<UseFileDialogOptions>) => void;
2703
+ open: (options?: Parameters<typeof openFileDialog>[0]) => void;
2695
2704
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
2696
2705
  error: (error: Error, files?: File[] | undefined) => any;
2697
2706
  select: (files: File[]) => any;
@@ -4063,6 +4072,8 @@ export declare interface ModelSelectorTriggerSlotProps {
4063
4072
 
4064
4073
  export declare type ModelSelectorVariant = 'outline' | 'ghost' | 'muted';
4065
4074
 
4075
+ declare const openFileDialog: (localOptions?: Partial<UseFileDialogOptions>) => void;
4076
+
4066
4077
  export declare type PluginAddState = 'idle' | 'loading' | 'added';
4067
4078
 
4068
4079
  export declare interface PluginCardEmits {
@@ -4341,21 +4352,7 @@ hasExternalContent: boolean;
4341
4352
  extensions: Extension[] | any[];
4342
4353
  submitType: SubmitTrigger;
4343
4354
  }, {}, string, {}, GlobalComponents, GlobalDirectives, string, ComponentProvideOptions> & VNodeProps & AllowedComponentProps & ComponentCustomProps & (new () => {
4344
- $slots: {
4345
- header?(_: {}): any;
4346
- header?(_: {}): any;
4347
- prefix?(_: {}): any;
4348
- prefix?(_: {}): any;
4349
- content?(_: {
4350
- editor: Editor | undefined;
4351
- }): any;
4352
- content?(_: {
4353
- editor: Ref<Editor | undefined, Editor | undefined>;
4354
- }): any;
4355
- 'actions-inline'?(_: {}): any;
4356
- footer?(_: {}): any;
4357
- 'footer-right'?(_: {}): any;
4358
- };
4355
+ $slots: Readonly<SenderSlots> & SenderSlots;
4359
4356
  }) & {
4360
4357
  install: <T>(app: App<T>) => void;
4361
4358
  Mention: Node_2<MentionOptions, any>;
package/dist/index3.js CHANGED
@@ -1,12 +1,12 @@
1
1
  var $ = Object.defineProperty;
2
- var D = (i, o, e) => o in i ? $(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
3
- var C = (i, o, e) => D(i, typeof o != "symbol" ? o + "" : o, e);
4
- import { defineComponent as B, toRefs as H, computed as R, watch as F, openBlock as S, createBlock as x, unref as p, ref as V, reactive as A, onUnmounted as P, createElementBlock as j, Fragment as U, normalizeClass as W, createSlots as L, withCtx as y, renderSlot as z, resolveDynamicComponent as M, createCommentVNode as N } from "vue";
5
- import { e as O } from "./index4.js";
6
- import { u as I, A as b } from "./index2.js";
7
- import { IconImageUpload as T, IconVoice as _, IconRecordingWave as q } from "@opentiny/tiny-robot-svgs";
8
- import { _ as G } from "./_plugin-vue_export-helper.js";
9
- const te = /* @__PURE__ */ B({
2
+ var F = (i, o, e) => o in i ? $(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e;
3
+ var x = (i, o, e) => F(i, typeof o != "symbol" ? o + "" : o, e);
4
+ import { defineComponent as I, toRefs as H, computed as v, watch as V, openBlock as R, createBlock as y, unref as m, ref as A, reactive as P, onUnmounted as j, createElementBlock as U, Fragment as W, normalizeClass as L, createSlots as M, withCtx as z, renderSlot as B, resolveDynamicComponent as N, createCommentVNode as O } from "vue";
5
+ import { e as T } from "./index4.js";
6
+ import { u as b, A as k } from "./index2.js";
7
+ import { IconImageUpload as _, IconVoice as q, IconRecordingWave as G } from "@opentiny/tiny-robot-svgs";
8
+ import { _ as J } from "./_plugin-vue_export-helper.js";
9
+ const ne = /* @__PURE__ */ I({
10
10
  __name: "index",
11
11
  props: {
12
12
  disabled: { type: Boolean },
@@ -22,48 +22,51 @@ const te = /* @__PURE__ */ B({
22
22
  },
23
23
  emits: ["select", "error"],
24
24
  setup(i, { expose: o, emit: e }) {
25
- const n = i, l = e, { accept: c, multiple: h, reset: m } = H(n), { disabled: a } = I(), t = R(() => n.disabled || a.value), { open: r, files: d } = O({
26
- accept: c,
27
- multiple: h,
28
- reset: m
29
- });
30
- F(d, (f) => {
31
- if (!f || f.length === 0) return;
32
- const g = Array.from(f);
33
- if (n.maxCount && g.length > n.maxCount) {
34
- const s = new Error(`最多只能选择 ${n.maxCount} 个文件`);
35
- l("error", s);
25
+ const n = i, l = e, { accept: c, multiple: g, reset: f } = H(n), { disabled: a } = b(), t = v(() => n.disabled || a.value), { open: s, files: d } = T(), u = (p) => {
26
+ s({
27
+ accept: c.value,
28
+ multiple: g.value,
29
+ reset: f.value,
30
+ ...p
31
+ });
32
+ };
33
+ V(d, (p) => {
34
+ if (!p || p.length === 0) return;
35
+ const r = Array.from(p);
36
+ if (n.maxCount && r.length > n.maxCount) {
37
+ const h = new Error(`最多只能选择 ${n.maxCount} 个文件`);
38
+ l("error", h);
36
39
  return;
37
40
  }
38
41
  if (n.maxSize) {
39
- const s = n.maxSize * 1024 * 1024, v = g.filter((E) => E.size > s);
40
- if (v.length > 0) {
41
- const E = new Error(`以下文件超过 ${n.maxSize}MB 限制: ${v.map((k) => k.name).join(", ")}`);
42
- l("error", E, v);
42
+ const h = n.maxSize * 1024 * 1024, E = r.filter((C) => C.size > h);
43
+ if (E.length > 0) {
44
+ const C = new Error(`以下文件超过 ${n.maxSize}MB 限制: ${E.map((D) => D.name).join(", ")}`);
45
+ l("error", C, E);
43
46
  return;
44
47
  }
45
48
  }
46
- l("select", g);
49
+ l("select", r);
47
50
  });
48
- const u = () => {
49
- t.value || r();
51
+ const w = () => {
52
+ t.value || u();
50
53
  };
51
54
  return o({
52
- open: r
53
- }), (f, g) => (S(), x(b, {
54
- icon: i.icon ?? p(T),
55
+ open: u
56
+ }), (p, r) => (R(), y(k, {
57
+ icon: i.icon ?? m(_),
55
58
  disabled: t.value,
56
59
  size: i.size,
57
60
  tooltip: i.tooltip,
58
61
  "tooltip-placement": i.tooltipPlacement,
59
- onClick: u
62
+ onClick: w
60
63
  }, null, 8, ["icon", "disabled", "size", "tooltip", "tooltip-placement"]));
61
64
  }
62
65
  });
63
- class w {
66
+ class S {
64
67
  constructor(o) {
65
- C(this, "recognition");
66
- C(this, "options");
68
+ x(this, "recognition");
69
+ x(this, "options");
67
70
  this.options = o, this.initialize();
68
71
  }
69
72
  /**
@@ -82,7 +85,7 @@ class w {
82
85
  * 检查浏览器是否支持 Web Speech API(实例方法)
83
86
  */
84
87
  isSupported() {
85
- return w.isSupported();
88
+ return S.isSupported();
86
89
  }
87
90
  /**
88
91
  * 设置语音识别事件处理器
@@ -136,8 +139,8 @@ class w {
136
139
  }
137
140
  }
138
141
  }
139
- function J(i) {
140
- const o = V(i), e = A({
142
+ function K(i) {
143
+ const o = A(i), e = P({
141
144
  isRecording: !1,
142
145
  isSupported: !1,
143
146
  error: void 0
@@ -147,25 +150,25 @@ function J(i) {
147
150
  e.isRecording = !0, e.error = void 0, (t = (a = o.value).onStart) == null || t.call(a);
148
151
  },
149
152
  onInterim: (a) => {
150
- var t, r;
151
- (r = (t = o.value).onInterim) == null || r.call(t, a);
153
+ var t, s;
154
+ (s = (t = o.value).onInterim) == null || s.call(t, a);
152
155
  },
153
156
  onFinal: (a) => {
154
- var t, r;
155
- (r = (t = o.value).onFinal) == null || r.call(t, a);
157
+ var t, s;
158
+ (s = (t = o.value).onFinal) == null || s.call(t, a);
156
159
  },
157
160
  onEnd: (a) => {
158
- var t, r;
159
- e.isRecording && (e.isRecording = !1, (r = (t = o.value).onEnd) == null || r.call(t, a));
161
+ var t, s;
162
+ e.isRecording && (e.isRecording = !1, (s = (t = o.value).onEnd) == null || s.call(t, a));
160
163
  },
161
164
  onError: (a) => {
162
- var t, r;
163
- e.error = a, e.isRecording = !1, (r = (t = o.value).onError) == null || r.call(t, a);
165
+ var t, s;
166
+ e.error = a, e.isRecording = !1, (s = (t = o.value).onError) == null || s.call(t, a);
164
167
  }
165
- }, l = w.isSupported();
168
+ }, l = S.isSupported();
166
169
  e.isSupported = i.customHandler ? i.customHandler.isSupported() : l;
167
- const c = i.customHandler ?? (l ? new w(i) : null), h = () => {
168
- var a, t, r, d;
170
+ const c = i.customHandler ?? (l ? new S(i) : null), g = () => {
171
+ var a, t, s, d;
169
172
  if (!e.isSupported || !c) {
170
173
  const u = new Error("语音识别不受支持");
171
174
  e.error = u, (t = (a = o.value).onError) == null || t.call(a, u);
@@ -180,20 +183,20 @@ function J(i) {
180
183
  try {
181
184
  c.start(n);
182
185
  } catch (u) {
183
- e.error = u instanceof Error ? u : new Error("启动失败"), (d = (r = o.value).onError) == null || d.call(r, e.error);
186
+ e.error = u instanceof Error ? u : new Error("启动失败"), (d = (s = o.value).onError) == null || d.call(s, e.error);
184
187
  }
185
- }, m = () => {
188
+ }, f = () => {
186
189
  !e.isRecording || !c || (c.stop(), n.onEnd());
187
190
  };
188
- return P(() => {
191
+ return j(() => {
189
192
  e.isRecording && c && (c.stop(), e.isRecording = !1);
190
193
  }), {
191
194
  speechState: e,
192
- start: h,
193
- stop: m
195
+ start: g,
196
+ stop: f
194
197
  };
195
198
  }
196
- const K = /* @__PURE__ */ B({
199
+ const Q = /* @__PURE__ */ I({
197
200
  __name: "index",
198
201
  props: {
199
202
  icon: {},
@@ -208,75 +211,75 @@ const K = /* @__PURE__ */ B({
208
211
  },
209
212
  emits: ["speech-start", "speech-interim", "speech-final", "speech-end", "speech-error"],
210
213
  setup(i, { expose: o, emit: e }) {
211
- const n = i, l = e, { editor: c, disabled: h } = I(), m = R(() => n.disabled || h.value), a = {
214
+ const n = i, l = e, { editor: c, disabled: g } = b(), f = v(() => n.disabled || g.value), a = {
212
215
  ...n.speechConfig,
213
216
  onStart: () => {
214
217
  l("speech-start");
215
218
  },
216
- onInterim: (s) => {
217
- l("speech-interim", s);
219
+ onInterim: (r) => {
220
+ l("speech-interim", r);
218
221
  },
219
- onFinal: (s) => {
220
- n.autoInsert && c.value && (c.value.commands.insertContent(s + " "), c.value.commands.focus("end")), l("speech-final", s);
222
+ onFinal: (r) => {
223
+ n.autoInsert && c.value && (c.value.commands.insertContent(r + " "), c.value.commands.focus("end")), l("speech-final", r);
221
224
  },
222
- onEnd: (s) => {
223
- c.value && c.value.commands.focus("end"), l("speech-end", s);
225
+ onEnd: (r) => {
226
+ c.value && c.value.commands.focus("end"), l("speech-end", r);
224
227
  },
225
- onError: (s) => {
226
- l("speech-error", s);
228
+ onError: (r) => {
229
+ l("speech-error", r);
227
230
  }
228
- }, { speechState: t, start: r, stop: d } = J(a), u = async () => {
229
- if (!m.value) {
231
+ }, { speechState: t, start: s, stop: d } = K(a), u = async () => {
232
+ if (!f.value) {
230
233
  if (n.onButtonClick) {
231
- let s = !1;
234
+ let r = !1;
232
235
  if (await n.onButtonClick(t.isRecording, () => {
233
- s = !0;
234
- }), s) return;
236
+ r = !0;
237
+ }), r) return;
235
238
  }
236
- t.isRecording ? d() : r();
239
+ t.isRecording ? d() : s();
237
240
  }
238
- }, f = R(() => n.icon ?? _), g = R(() => n.recordingIcon ?? q);
241
+ }, w = v(() => n.icon ?? q), p = v(() => n.recordingIcon ?? G);
239
242
  return o({
240
- start: r,
243
+ start: s,
241
244
  stop: d,
242
245
  speechState: t
243
- }), (s, v) => (S(), j(U, null, [
244
- p(t).isSupported ? (S(), x(b, {
246
+ }), (r, h) => (R(), U(W, null, [
247
+ m(t).isSupported ? (R(), y(k, {
245
248
  key: 0,
246
- icon: f.value,
247
- disabled: m.value,
249
+ icon: w.value,
250
+ disabled: f.value,
248
251
  size: i.size,
249
252
  tooltip: i.tooltip,
250
253
  "tooltip-placement": i.tooltipPlacement,
251
- class: W({ "is-recording": p(t).isRecording }),
254
+ class: L({ "is-recording": m(t).isRecording }),
252
255
  onClick: u
253
- }, L({ _: 2 }, [
254
- s.$slots.icon ? {
256
+ }, M({ _: 2 }, [
257
+ r.$slots.icon ? {
255
258
  name: "icon",
256
- fn: y(() => [
257
- z(s.$slots, "icon", {
258
- isRecording: p(t).isRecording
259
+ fn: z(() => [
260
+ B(r.$slots, "icon", {
261
+ isRecording: m(t).isRecording
259
262
  }, void 0, !0)
260
263
  ]),
261
264
  key: "0"
262
- } : p(t).isRecording ? {
265
+ } : m(t).isRecording ? {
263
266
  name: "icon",
264
- fn: y(() => [
265
- (S(), x(M(g.value)))
267
+ fn: z(() => [
268
+ (R(), y(N(p.value)))
266
269
  ]),
267
270
  key: "1"
268
271
  } : void 0
269
- ]), 1032, ["icon", "disabled", "size", "tooltip", "tooltip-placement", "class"])) : N("", !0),
270
- z(s.$slots, "recording-overlay", {
271
- isRecording: p(t).isRecording,
272
- stop: p(d)
272
+ ]), 1032, ["icon", "disabled", "size", "tooltip", "tooltip-placement", "class"])) : O("", !0),
273
+ B(r.$slots, "recording-overlay", {
274
+ isRecording: m(t).isRecording,
275
+ stop: m(d)
273
276
  }, void 0, !0)
274
277
  ], 64));
275
278
  }
276
- }), ne = /* @__PURE__ */ G(K, [["__scopeId", "data-v-2a013fc9"]]);
279
+ }), ie = /* @__PURE__ */ J(Q, [["__scopeId", "data-v-2a013fc9"]]);
277
280
  export {
278
- ne as V,
279
- w as W,
280
- te as _,
281
- J as u
281
+ ie as V,
282
+ S as W,
283
+ ne as _,
284
+ K as u
282
285
  };