@vunk/plus 1.2.2 → 1.3.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.
Files changed (119) hide show
  1. package/components/SendOutlined.mjs +1 -1
  2. package/components/agent-chat-provider/index.mjs +789 -0
  3. package/components/avatar/index.mjs +2 -2
  4. package/components/broadcasting-markdown/index.css +3 -0
  5. package/components/broadcasting-markdown/index.mjs +637 -0
  6. package/components/bubble-list/index.css +18 -0
  7. package/components/bubble-list/index.mjs +386 -0
  8. package/components/bubble-templates/index.css +18 -0
  9. package/components/bubble-templates/index.mjs +258 -0
  10. package/components/chat-independent/index.css +47 -0
  11. package/components/chat-independent/index.mjs +184 -0
  12. package/components/index.mjs +35980 -0
  13. package/components/lottie-animation/index.mjs +2 -2
  14. package/components/monaco-editor/index.mjs +2 -2
  15. package/components/monaco-environment/index.mjs +1 -1
  16. package/components/recorder-button/index.css +7 -10
  17. package/components/recorder-button/index.mjs +115 -83
  18. package/components/routes-menu-content/index.mjs +5 -5
  19. package/components/sender/index.css +2 -5
  20. package/components/sender/index.mjs +31 -12
  21. package/components/speech-button/index.mjs +6 -13
  22. package/components/table-columns/index.mjs +3 -6
  23. package/components/tables-v1/index.mjs +3 -3
  24. package/components/tables-v1-checkbox/index.mjs +269 -33
  25. package/components/typing-markdown/index.mjs +128 -33
  26. package/components/vditor/index.mjs +5 -9
  27. package/composables/el-breakpoints/index.d.ts +1 -1
  28. package/composables/recorder/index.mjs +751 -182
  29. package/icons/_plugin-vue_export-helper.mjs +9 -0
  30. package/icons/end/index.d.ts +4 -0
  31. package/icons/end/index.mjs +36 -0
  32. package/icons/end/src/avatar.d.ts +12 -0
  33. package/icons/end/src/icon.d.ts +57 -0
  34. package/icons/keyboard/index.d.ts +4 -0
  35. package/icons/keyboard/index.mjs +36 -0
  36. package/icons/keyboard/src/avatar.d.ts +12 -0
  37. package/icons/keyboard/src/icon.d.ts +57 -0
  38. package/icons/start/index.d.ts +4 -0
  39. package/icons/start/index.mjs +36 -0
  40. package/icons/start/src/avatar.d.ts +12 -0
  41. package/icons/start/src/icon.d.ts +57 -0
  42. package/icons/voice/index.d.ts +4 -0
  43. package/icons/voice/index.mjs +51 -0
  44. package/icons/voice/src/avatar.d.ts +12 -0
  45. package/icons/voice/src/icon.d.ts +57 -0
  46. package/icons/voice/src/index.vue.d.ts +4 -0
  47. package/index.css +99 -15
  48. package/package.json +51 -7
  49. package/components/avatar/index.d.ts +0 -4
  50. package/components/avatar/src/ctx.d.ts +0 -18
  51. package/components/avatar/src/index.vue.d.ts +0 -180
  52. package/components/avatar/src/types.d.ts +0 -1
  53. package/components/lottie-animation/index.d.ts +0 -4
  54. package/components/lottie-animation/src/ctx.d.ts +0 -10
  55. package/components/lottie-animation/src/index.vue.d.ts +0 -21
  56. package/components/lottie-animation/src/types.d.ts +0 -4
  57. package/components/monaco-editor/index.d.ts +0 -5
  58. package/components/monaco-editor/src/ctx.d.ts +0 -23
  59. package/components/monaco-editor/src/index.vue.d.ts +0 -40
  60. package/components/monaco-editor/src/types.d.ts +0 -1
  61. package/components/monaco-environment/index.d.ts +0 -4
  62. package/components/monaco-environment/src/ctx.d.ts +0 -8
  63. package/components/monaco-environment/src/index.vue.d.ts +0 -2
  64. package/components/monaco-environment/src/types.d.ts +0 -1
  65. package/components/recorder-button/index.d.ts +0 -4
  66. package/components/recorder-button/src/ctx.d.ts +0 -19
  67. package/components/recorder-button/src/index.vue.d.ts +0 -309
  68. package/components/recorder-button/src/speech-to-text.d.ts +0 -1
  69. package/components/recorder-button/src/types.d.ts +0 -6
  70. package/components/routes-menu-content/index.d.ts +0 -4
  71. package/components/routes-menu-content/src/ctx.d.ts +0 -17
  72. package/components/routes-menu-content/src/index.vue.d.ts +0 -350
  73. package/components/routes-menu-content/src/item/core/ctx.d.ts +0 -18
  74. package/components/routes-menu-content/src/item/core/index.vue.d.ts +0 -185
  75. package/components/routes-menu-content/src/item/ctx.d.ts +0 -14
  76. package/components/routes-menu-content/src/item/index.vue.d.ts +0 -316
  77. package/components/routes-menu-content/src/types.d.ts +0 -1
  78. package/components/sender/index.d.ts +0 -4
  79. package/components/sender/src/SenderHeader.vue.d.ts +0 -270
  80. package/components/sender/src/ctx.d.ts +0 -38
  81. package/components/sender/src/index.vue.d.ts +0 -732
  82. package/components/sender/src/types.d.ts +0 -1
  83. package/components/speech-button/index.d.ts +0 -4
  84. package/components/speech-button/src/LoadingIcon.vue.d.ts +0 -2
  85. package/components/speech-button/src/RecordingIcon.vue.d.ts +0 -2
  86. package/components/speech-button/src/ctx.d.ts +0 -10
  87. package/components/speech-button/src/index.vue.d.ts +0 -22
  88. package/components/speech-button/src/types.d.ts +0 -1
  89. package/components/table-columns/index.d.ts +0 -5
  90. package/components/table-columns/src/ctx.d.ts +0 -66
  91. package/components/table-columns/src/el-ctx.d.ts +0 -63
  92. package/components/table-columns/src/index.vue.d.ts +0 -280
  93. package/components/table-columns/src/types.d.ts +0 -21
  94. package/components/tables-v1/index.d.ts +0 -5
  95. package/components/tables-v1/src/ctx.d.ts +0 -283
  96. package/components/tables-v1/src/el-ctx.d.ts +0 -272
  97. package/components/tables-v1/src/index.vue.d.ts +0 -2997
  98. package/components/tables-v1/src/types.d.ts +0 -4
  99. package/components/tables-v1-checkbox/index.d.ts +0 -5
  100. package/components/tables-v1-checkbox/src/ctx.d.ts +0 -323
  101. package/components/tables-v1-checkbox/src/index.vue.d.ts +0 -3788
  102. package/components/tables-v1-checkbox/src/types.d.ts +0 -1
  103. package/components/typing-markdown/index.d.ts +0 -4
  104. package/components/typing-markdown/src/core.d.ts +0 -3
  105. package/components/typing-markdown/src/ctx.d.ts +0 -33
  106. package/components/typing-markdown/src/index.vue.d.ts +0 -57
  107. package/components/typing-markdown/src/types.d.ts +0 -1
  108. package/components/vditor/index.d.ts +0 -5
  109. package/components/vditor/src/ctx.d.ts +0 -37
  110. package/components/vditor/src/handle-fullscreen.vue.d.ts +0 -18
  111. package/components/vditor/src/handle-value.vue.d.ts +0 -18
  112. package/components/vditor/src/index.vue.d.ts +0 -144
  113. package/components/vditor/src/types.d.ts +0 -9
  114. package/components/vditor/src/use.d.ts +0 -4
  115. package/fetch/PlusFetch/index.d.ts +0 -14
  116. package/fetch/PlusFetch/index.mjs +0 -638
  117. package/fetch/PlusFetch/types.d.ts +0 -54
  118. package/fetch/index.d.ts +0 -1
  119. package/fetch/index.mjs +0 -5
@@ -0,0 +1,184 @@
1
+ import { defineComponent, ref, computed, createElementBlock, openBlock, createElementVNode, createVNode, unref, withCtx, withDirectives, vShow, renderSlot, nextTick } from 'vue';
2
+ import { useAgentChat } from '@vunk/plus/components/agent-chat-provider';
3
+ import { VkBubbleList } from '@vunk/plus/components/bubble-list';
4
+ import { VkRecorderButton } from '@vunk/plus/components/recorder-button';
5
+ import { VkSender } from '@vunk/plus/components/sender';
6
+ import { VkKeyboardAvatar } from '@vunk/plus/icons/keyboard';
7
+ import { VkVoiceAvatar } from '@vunk/plus/icons/voice';
8
+ import { VkDuplex } from '@vunk/core';
9
+ import { VkRendererData } from '@vunk/core/components/renderer-data';
10
+ import { useDataComputed, useDeferred } from '@vunk/core/composables';
11
+
12
+ var InputType = /* @__PURE__ */ ((InputType2) => {
13
+ InputType2["Voice"] = "voice";
14
+ InputType2["Text"] = "text";
15
+ return InputType2;
16
+ })(InputType || {});
17
+
18
+ const props = {
19
+ /**
20
+ * @description BubbleList渲染时数据, 受控于setData
21
+ */
22
+ data: {
23
+ type: Object
24
+ },
25
+ speechToText: {
26
+ type: Function
27
+ },
28
+ textToSpeech: {
29
+ type: Function
30
+ }
31
+ };
32
+ const emits = {
33
+ setData: (e) => e
34
+ };
35
+
36
+ const _hoisted_1 = { class: "vk-chat-independent" };
37
+ const _hoisted_2 = { class: "vk-chat-independent-main__bubbles" };
38
+ const _hoisted_3 = { class: "vk-chat-independent-footer" };
39
+ const _hoisted_4 = { class: "vk-chat-independent-background" };
40
+ var _sfc_main = /* @__PURE__ */ defineComponent({
41
+ ...{
42
+ name: "VkChatIndependent"
43
+ },
44
+ __name: "index",
45
+ props: props,
46
+ emits: emits,
47
+ setup(__props, { emit: __emit }) {
48
+ const props = __props;
49
+ const emit = __emit;
50
+ const [bubbleData, setBubbleData] = useDataComputed({}, props, emit);
51
+ const mainRef = ref();
52
+ const inputType = ref(InputType.Text);
53
+ const content = ref("");
54
+ const bubbleListDef = useDeferred();
55
+ const bubbleListReslove = bubbleListDef.resolve;
56
+ const { simplicity } = useAgentChat();
57
+ const { items: bubbleItems, onRequest } = simplicity;
58
+ const lastBubbleData = computed(() => {
59
+ const key = bubbleItems.value.at(-1)?.key;
60
+ if (key && bubbleData.value[key]) {
61
+ return bubbleData.value[key];
62
+ }
63
+ return {};
64
+ });
65
+ const senderDisabled = computed(() => {
66
+ if (lastBubbleData.value.error === true) {
67
+ return false;
68
+ }
69
+ return bubbleItems.value.at(-1)?.loading === true || lastBubbleData.value.completed === false;
70
+ });
71
+ function onSubmit(nextContent) {
72
+ if (!nextContent)
73
+ return;
74
+ onRequest(nextContent);
75
+ nextTick(() => {
76
+ content.value = "";
77
+ });
78
+ setTimeout(() => {
79
+ bubbleListDef.value?.scrollToBottom();
80
+ }, 400);
81
+ }
82
+ return (_ctx, _cache) => {
83
+ return openBlock(), createElementBlock("div", _hoisted_1, [
84
+ createElementVNode(
85
+ "div",
86
+ {
87
+ ref_key: "mainRef",
88
+ ref: mainRef,
89
+ class: "vk-chat-independent-main"
90
+ },
91
+ [
92
+ createVNode(unref(VkDuplex), {
93
+ "with-flex": "one",
94
+ class: "vk-chat-independent-main__duplex"
95
+ }, {
96
+ one: withCtx(() => [
97
+ createVNode(unref(VkRendererData), {
98
+ data: unref(bubbleData),
99
+ onSetData: unref(setBubbleData)
100
+ }, {
101
+ default: withCtx(() => [
102
+ createElementVNode("div", _hoisted_2, [
103
+ createVNode(unref(VkBubbleList), {
104
+ "el-ref": unref(bubbleListReslove),
105
+ items: unref(bubbleItems),
106
+ "text-to-speech": _ctx.textToSpeech
107
+ }, null, 8, ["el-ref", "items", "text-to-speech"])
108
+ ])
109
+ ]),
110
+ _: 1
111
+ /* STABLE */
112
+ }, 8, ["data", "onSetData"])
113
+ ]),
114
+ two: withCtx(() => [
115
+ createElementVNode("div", _hoisted_3, [
116
+ withDirectives(createVNode(
117
+ unref(VkKeyboardAvatar),
118
+ {
119
+ size: 40,
120
+ onClick: _cache[0] || (_cache[0] = ($event) => inputType.value = unref(InputType).Text)
121
+ },
122
+ null,
123
+ 512
124
+ /* NEED_PATCH */
125
+ ), [
126
+ [vShow, inputType.value === unref(InputType).Voice]
127
+ ]),
128
+ withDirectives(createVNode(
129
+ unref(VkVoiceAvatar),
130
+ {
131
+ size: 40,
132
+ onClick: _cache[1] || (_cache[1] = ($event) => inputType.value = unref(InputType).Voice)
133
+ },
134
+ null,
135
+ 512
136
+ /* NEED_PATCH */
137
+ ), [
138
+ [vShow, inputType.value === unref(InputType).Text]
139
+ ]),
140
+ withDirectives(createVNode(unref(VkRecorderButton), {
141
+ "append-to": mainRef.value,
142
+ disabled: senderDisabled.value,
143
+ "speech-to-text": _ctx.speechToText,
144
+ "submit-to-text": true,
145
+ onSubmitText: onSubmit
146
+ }, null, 8, ["append-to", "disabled", "speech-to-text"]), [
147
+ [vShow, inputType.value === unref(InputType).Voice]
148
+ ]),
149
+ withDirectives(createVNode(unref(VkSender), {
150
+ modelValue: content.value,
151
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => content.value = $event),
152
+ "auto-size": true,
153
+ placeholder: "\u8BF7\u8F93\u5165\u5185\u5BB9",
154
+ disabled: senderDisabled.value,
155
+ onSubmit
156
+ }, null, 8, ["modelValue", "disabled"]), [
157
+ [vShow, inputType.value === unref(InputType).Text]
158
+ ])
159
+ ])
160
+ ]),
161
+ _: 1
162
+ /* STABLE */
163
+ })
164
+ ],
165
+ 512
166
+ /* NEED_PATCH */
167
+ ),
168
+ createElementVNode("div", _hoisted_4, [
169
+ renderSlot(_ctx.$slots, "background")
170
+ ])
171
+ ]);
172
+ };
173
+ }
174
+ });
175
+
176
+ var types = /*#__PURE__*/Object.freeze({
177
+ __proto__: null
178
+ });
179
+
180
+ _sfc_main.install = (app) => {
181
+ app.component(_sfc_main.name || "VkChatIndependent", _sfc_main);
182
+ };
183
+
184
+ export { _sfc_main as VkChatIndependent, types as __VkChatIndependent, _sfc_main as default };