@fv-ui/ai-chat 0.9.0 → 0.9.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.
package/dist/index.d.ts CHANGED
@@ -134,7 +134,7 @@ declare var __VLS_1$9: {};
134
134
  declare var __VLS_10$1: {};
135
135
  declare var __VLS_12$1: {};
136
136
  declare var __VLS_14: {};
137
- declare var __VLS_32$1: {};
137
+ declare var __VLS_32: {};
138
138
  type __VLS_Slots$e = {} & {
139
139
  avatar?: (props: typeof __VLS_1$9) => any;
140
140
  } & {
@@ -144,7 +144,7 @@ type __VLS_Slots$e = {} & {
144
144
  } & {
145
145
  content?: (props: typeof __VLS_14) => any;
146
146
  } & {
147
- footer?: (props: typeof __VLS_32$1) => any;
147
+ footer?: (props: typeof __VLS_32) => any;
148
148
  };
149
149
  declare const __VLS_base$e: vue.DefineComponent<__VLS_Props$f, {
150
150
  interrupt: typeof interrupt;
@@ -822,16 +822,16 @@ type __VLS_Props$a = {
822
822
  /** 切换门控:start 起始态不可切换;thinking 中可展开查看思考流,end/error 后可自由收起展开 */
823
823
  declare function toggle(): void;
824
824
  declare var __VLS_1$6: {};
825
- declare var __VLS_36$1: {};
826
- declare var __VLS_38$1: {};
825
+ declare var __VLS_36$2: {};
826
+ declare var __VLS_38: {};
827
827
  declare var __VLS_51: {};
828
828
  declare var __VLS_53: {};
829
829
  type __VLS_Slots$9 = {} & {
830
830
  'status-icon'?: (props: typeof __VLS_1$6) => any;
831
831
  } & {
832
- label?: (props: typeof __VLS_36$1) => any;
832
+ label?: (props: typeof __VLS_36$2) => any;
833
833
  } & {
834
- arrow?: (props: typeof __VLS_38$1) => any;
834
+ arrow?: (props: typeof __VLS_38) => any;
835
835
  } & {
836
836
  error?: (props: typeof __VLS_51) => any;
837
837
  } & {
@@ -908,13 +908,13 @@ type __VLS_Props$8 = {
908
908
  };
909
909
  declare var __VLS_1$5: {};
910
910
  declare var __VLS_24$1: {};
911
- declare var __VLS_26$1: {};
911
+ declare var __VLS_26: {};
912
912
  type __VLS_Slots$7 = {} & {
913
913
  icon?: (props: typeof __VLS_1$5) => any;
914
914
  } & {
915
915
  name?: (props: typeof __VLS_24$1) => any;
916
916
  } & {
917
- description?: (props: typeof __VLS_26$1) => any;
917
+ description?: (props: typeof __VLS_26) => any;
918
918
  };
919
919
  declare const __VLS_base$7: vue.DefineComponent<__VLS_Props$8, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<__VLS_Props$8> & Readonly<{}>, {
920
920
  name: string;
@@ -1522,43 +1522,43 @@ declare function scrollToBottom(smooth?: boolean): void;
1522
1522
  /** 回到顶部:与 scrollToBottom 同款 try/catch 回落(happy-dom 旧版 scrollTo(options) 可能缺实现) */
1523
1523
  declare function scrollToTop(): void;
1524
1524
  declare var __VLS_1$1: {};
1525
- declare var __VLS_26: {
1525
+ declare var __VLS_27$1: {
1526
1526
  message: MessageNode;
1527
1527
  };
1528
- declare var __VLS_29$1: {
1528
+ declare var __VLS_30$1: {
1529
1529
  message: MessageNode;
1530
1530
  };
1531
- declare var __VLS_32: {};
1532
- declare var __VLS_35: {};
1533
- declare var __VLS_38: {
1531
+ declare var __VLS_33$2: {};
1532
+ declare var __VLS_36$1: {};
1533
+ declare var __VLS_39$1: {
1534
1534
  message: MessageNode;
1535
1535
  };
1536
- declare var __VLS_41: {
1536
+ declare var __VLS_42$1: {
1537
1537
  message: MessageNode;
1538
1538
  };
1539
- declare var __VLS_49: {
1539
+ declare var __VLS_50: {
1540
1540
  scrollToBottom: typeof scrollToBottom;
1541
1541
  awayFromBottom: boolean;
1542
1542
  };
1543
- declare var __VLS_65: {};
1543
+ declare var __VLS_66: {};
1544
1544
  type __VLS_Slots$2 = {} & {
1545
1545
  empty?: (props: typeof __VLS_1$1) => any;
1546
1546
  } & {
1547
- 'message-avatar'?: (props: typeof __VLS_26) => any;
1547
+ 'message-avatar'?: (props: typeof __VLS_27$1) => any;
1548
1548
  } & {
1549
- 'message-actions'?: (props: typeof __VLS_29$1) => any;
1549
+ 'message-actions'?: (props: typeof __VLS_30$1) => any;
1550
1550
  } & {
1551
- 'user-avatar'?: (props: typeof __VLS_32) => any;
1551
+ 'user-avatar'?: (props: typeof __VLS_33$2) => any;
1552
1552
  } & {
1553
- 'assistant-avatar'?: (props: typeof __VLS_35) => any;
1553
+ 'assistant-avatar'?: (props: typeof __VLS_36$1) => any;
1554
1554
  } & {
1555
- 'user-name'?: (props: typeof __VLS_38) => any;
1555
+ 'user-name'?: (props: typeof __VLS_39$1) => any;
1556
1556
  } & {
1557
- 'assistant-name'?: (props: typeof __VLS_41) => any;
1557
+ 'assistant-name'?: (props: typeof __VLS_42$1) => any;
1558
1558
  } & {
1559
- 'scroll-button'?: (props: typeof __VLS_49) => any;
1559
+ 'scroll-button'?: (props: typeof __VLS_50) => any;
1560
1560
  } & {
1561
- 'scroll-button-icon'?: (props: typeof __VLS_65) => any;
1561
+ 'scroll-button-icon'?: (props: typeof __VLS_66) => any;
1562
1562
  };
1563
1563
  declare const __VLS_base$2: vue.DefineComponent<__VLS_Props$3, {
1564
1564
  scrollToBottom: typeof scrollToBottom;
@@ -1865,7 +1865,7 @@ declare var __VLS_33: {
1865
1865
  message: MessageNode;
1866
1866
  files: ChatFile[];
1867
1867
  };
1868
- declare var __VLS_67: {
1868
+ declare var __VLS_71: {
1869
1869
  message: MessageNode;
1870
1870
  };
1871
1871
  type __VLS_Slots = {} & {
@@ -1881,15 +1881,17 @@ type __VLS_Slots = {} & {
1881
1881
  } & {
1882
1882
  'message-files'?: (props: typeof __VLS_33) => any;
1883
1883
  } & {
1884
- 'message-actions'?: (props: typeof __VLS_67) => any;
1884
+ 'message-actions'?: (props: typeof __VLS_71) => any;
1885
1885
  };
1886
1886
  declare const __VLS_base: vue.DefineComponent<__VLS_Props$1, {
1887
1887
  message: vue.ComputedRef<MessageNode>;
1888
1888
  }, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {} & {
1889
+ typing: () => any;
1889
1890
  copy: (message: MessageNode) => any;
1890
1891
  regenerate: (message: MessageNode) => any;
1891
1892
  "branch-change": (dir: BranchDirection, message: MessageNode) => any;
1892
1893
  }, string, vue.PublicProps, Readonly<__VLS_Props$1> & Readonly<{
1894
+ onTyping?: (() => any) | undefined;
1893
1895
  onCopy?: ((message: MessageNode) => any) | undefined;
1894
1896
  onRegenerate?: ((message: MessageNode) => any) | undefined;
1895
1897
  "onBranch-change"?: ((dir: BranchDirection, message: MessageNode) => any) | undefined;
package/es/index.mjs CHANGED
@@ -6086,7 +6086,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6086
6086
  autoCollapse: { type: Boolean, required: false, default: true },
6087
6087
  typing: { type: [Boolean, Object], required: false, default: false }
6088
6088
  },
6089
- emits: ["copy", "regenerate", "branch-change"],
6089
+ emits: ["copy", "regenerate", "branch-change", "typing"],
6090
6090
  setup(__props, { expose: __expose, emit: __emit }) {
6091
6091
  const props = __props;
6092
6092
  const emit = __emit;
@@ -6099,9 +6099,15 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6099
6099
  });
6100
6100
  const hasReasoning = computed(() => !!props.message.reasoning);
6101
6101
  const hasToolSteps = computed(() => (props.message.toolSteps?.length ?? 0) > 0);
6102
- const useTypewriter = computed(
6103
- () => !isUser.value && !!props.typing && (props.message.status === "pending" || props.message.status === "streaming")
6102
+ const wasStreaming = ref(false);
6103
+ watch(
6104
+ () => props.message.status,
6105
+ (s) => {
6106
+ if (s === "pending" || s === "streaming") wasStreaming.value = true;
6107
+ },
6108
+ { immediate: true }
6104
6109
  );
6110
+ const useTypewriter = computed(() => !isUser.value && !!props.typing && wasStreaming.value);
6105
6111
  const toolChainItems = computed(() => {
6106
6112
  const steps = props.message.toolSteps ?? [];
6107
6113
  const running = props.message.status === "pending" || props.message.status === "streaming";
@@ -6249,7 +6255,8 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6249
6255
  key: 0,
6250
6256
  content: __props.message.reasoning ?? "",
6251
6257
  "is-markdown": "",
6252
- typing: __props.typing
6258
+ typing: __props.typing,
6259
+ onWriting: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6253
6260
  }, null, 8, ["content", "typing"])) : (openBlock(), createBlock(_sfc_main$i, {
6254
6261
  key: 1,
6255
6262
  content: __props.message.reasoning ?? ""
@@ -6270,7 +6277,8 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6270
6277
  key: 1,
6271
6278
  content: __props.message.content,
6272
6279
  "is-markdown": "",
6273
- typing: __props.typing
6280
+ typing: __props.typing,
6281
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6274
6282
  }, null, 8, ["content", "typing"])) : __props.message.content ? (openBlock(), createBlock(_sfc_main$i, {
6275
6283
  key: 2,
6276
6284
  content: __props.message.content
@@ -6401,7 +6409,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6401
6409
  class: "fv-msg-action",
6402
6410
  disabled: __props.branch.index <= 1,
6403
6411
  "aria-label": "\u4E0A\u4E00\u5206\u652F",
6404
- onClick: _cache[0] || (_cache[0] = ($event) => onBranch("prev"))
6412
+ onClick: _cache[2] || (_cache[2] = ($event) => onBranch("prev"))
6405
6413
  }, {
6406
6414
  default: withCtx(() => [
6407
6415
  createVNode(unref(ElIcon), null, {
@@ -6428,7 +6436,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6428
6436
  class: "fv-msg-action",
6429
6437
  disabled: __props.branch.index >= __props.branch.count,
6430
6438
  "aria-label": "\u4E0B\u4E00\u5206\u652F",
6431
- onClick: _cache[1] || (_cache[1] = ($event) => onBranch("next"))
6439
+ onClick: _cache[3] || (_cache[3] = ($event) => onBranch("next"))
6432
6440
  }, {
6433
6441
  default: withCtx(() => [
6434
6442
  createVNode(unref(ElIcon), null, {
@@ -6486,6 +6494,9 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6486
6494
  setup(__props, { expose: __expose, emit: __emit }) {
6487
6495
  const props = __props;
6488
6496
  const emit = __emit;
6497
+ function onChildTyping() {
6498
+ followIfPinned();
6499
+ }
6489
6500
  const isEmpty = computed(() => props.messages.length === 0);
6490
6501
  const scrollRef = ref(null);
6491
6502
  function distanceFromBottom() {
@@ -6634,6 +6645,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6634
6645
  "user-name": __props.userName,
6635
6646
  "assistant-name": __props.assistantName,
6636
6647
  typing: __props.typing,
6648
+ onTyping: onChildTyping,
6637
6649
  onCopy,
6638
6650
  onRegenerate,
6639
6651
  onBranchChange: onBranch
package/lib/index.js CHANGED
@@ -6102,7 +6102,7 @@ ${fileParts.join("\n")}` });
6102
6102
  autoCollapse: { type: Boolean, required: false, default: true },
6103
6103
  typing: { type: [Boolean, Object], required: false, default: false }
6104
6104
  },
6105
- emits: ["copy", "regenerate", "branch-change"],
6105
+ emits: ["copy", "regenerate", "branch-change", "typing"],
6106
6106
  setup(__props, { expose: __expose, emit: __emit }) {
6107
6107
  const props = __props;
6108
6108
  const emit = __emit;
@@ -6115,9 +6115,15 @@ ${fileParts.join("\n")}` });
6115
6115
  });
6116
6116
  const hasReasoning = vue.computed(() => !!props.message.reasoning);
6117
6117
  const hasToolSteps = vue.computed(() => (props.message.toolSteps?.length ?? 0) > 0);
6118
- const useTypewriter = vue.computed(
6119
- () => !isUser.value && !!props.typing && (props.message.status === "pending" || props.message.status === "streaming")
6118
+ const wasStreaming = vue.ref(false);
6119
+ vue.watch(
6120
+ () => props.message.status,
6121
+ (s) => {
6122
+ if (s === "pending" || s === "streaming") wasStreaming.value = true;
6123
+ },
6124
+ { immediate: true }
6120
6125
  );
6126
+ const useTypewriter = vue.computed(() => !isUser.value && !!props.typing && wasStreaming.value);
6121
6127
  const toolChainItems = vue.computed(() => {
6122
6128
  const steps = props.message.toolSteps ?? [];
6123
6129
  const running = props.message.status === "pending" || props.message.status === "streaming";
@@ -6265,7 +6271,8 @@ ${fileParts.join("\n")}` });
6265
6271
  key: 0,
6266
6272
  content: __props.message.reasoning ?? "",
6267
6273
  "is-markdown": "",
6268
- typing: __props.typing
6274
+ typing: __props.typing,
6275
+ onWriting: _cache[0] || (_cache[0] = ($event) => emit("typing"))
6269
6276
  }, null, 8, ["content", "typing"])) : (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6270
6277
  key: 1,
6271
6278
  content: __props.message.reasoning ?? ""
@@ -6286,7 +6293,8 @@ ${fileParts.join("\n")}` });
6286
6293
  key: 1,
6287
6294
  content: __props.message.content,
6288
6295
  "is-markdown": "",
6289
- typing: __props.typing
6296
+ typing: __props.typing,
6297
+ onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
6290
6298
  }, null, 8, ["content", "typing"])) : __props.message.content ? (vue.openBlock(), vue.createBlock(_sfc_main$i, {
6291
6299
  key: 2,
6292
6300
  content: __props.message.content
@@ -6417,7 +6425,7 @@ ${fileParts.join("\n")}` });
6417
6425
  class: "fv-msg-action",
6418
6426
  disabled: __props.branch.index <= 1,
6419
6427
  "aria-label": "\u4E0A\u4E00\u5206\u652F",
6420
- onClick: _cache[0] || (_cache[0] = ($event) => onBranch("prev"))
6428
+ onClick: _cache[2] || (_cache[2] = ($event) => onBranch("prev"))
6421
6429
  }, {
6422
6430
  default: vue.withCtx(() => [
6423
6431
  vue.createVNode(vue.unref(elementPlus.ElIcon), null, {
@@ -6444,7 +6452,7 @@ ${fileParts.join("\n")}` });
6444
6452
  class: "fv-msg-action",
6445
6453
  disabled: __props.branch.index >= __props.branch.count,
6446
6454
  "aria-label": "\u4E0B\u4E00\u5206\u652F",
6447
- onClick: _cache[1] || (_cache[1] = ($event) => onBranch("next"))
6455
+ onClick: _cache[3] || (_cache[3] = ($event) => onBranch("next"))
6448
6456
  }, {
6449
6457
  default: vue.withCtx(() => [
6450
6458
  vue.createVNode(vue.unref(elementPlus.ElIcon), null, {
@@ -6502,6 +6510,9 @@ ${fileParts.join("\n")}` });
6502
6510
  setup(__props, { expose: __expose, emit: __emit }) {
6503
6511
  const props = __props;
6504
6512
  const emit = __emit;
6513
+ function onChildTyping() {
6514
+ followIfPinned();
6515
+ }
6505
6516
  const isEmpty = vue.computed(() => props.messages.length === 0);
6506
6517
  const scrollRef = vue.ref(null);
6507
6518
  function distanceFromBottom() {
@@ -6650,6 +6661,7 @@ ${fileParts.join("\n")}` });
6650
6661
  "user-name": __props.userName,
6651
6662
  "assistant-name": __props.assistantName,
6652
6663
  typing: __props.typing,
6664
+ onTyping: onChildTyping,
6653
6665
  onCopy,
6654
6666
  onRegenerate,
6655
6667
  onBranchChange: onBranch
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fv-ui/ai-chat",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "基于 Vue3 + Element Plus 的 AI 对话组件库",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",