@vunk/plus 1.12.1 → 1.13.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 (174) hide show
  1. package/components/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  2. package/components/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
  3. package/components/agent-chat-provider/index.cjs +1 -0
  4. package/components/agent-chat-provider/index.mjs +113 -187
  5. package/components/agent-chat-provider/src/index.vue.d.ts +3 -2
  6. package/components/avatar/index.cjs +1 -0
  7. package/components/avatar/index.mjs +25 -31
  8. package/components/avatar/src/index.vue.d.ts +40 -39
  9. package/components/broadcasting-markdown/__tests__/const.test.d.ts +1 -0
  10. package/components/broadcasting-markdown/__tests__/utils.test.d.ts +1 -0
  11. package/components/broadcasting-markdown/index.cjs +5 -0
  12. package/components/broadcasting-markdown/index.mjs +346 -4376
  13. package/components/broadcasting-markdown/src/howler-speech.vue.d.ts +18 -24
  14. package/components/broadcasting-markdown/src/index.vue.d.ts +101 -51
  15. package/components/broadcasting-markdown/src/paragraph.vue.d.ts +17 -29
  16. package/components/broadcasting-markdown/src/speech-error.vue.d.ts +2 -59
  17. package/components/bubble-list/index.cjs +1 -0
  18. package/components/bubble-list/index.mjs +220 -302
  19. package/components/bubble-list/src/core/index.vue.d.ts +40 -885
  20. package/components/bubble-list/src/core/loading.vue.d.ts +3 -0
  21. package/components/bubble-list/src/index.vue.d.ts +29 -1321
  22. package/components/bubble-templates/index.cjs +1 -0
  23. package/components/bubble-templates/index.mjs +34 -49
  24. package/components/bubble-templates/src/index.vue.d.ts +3 -224
  25. package/components/chat-independent/index.cjs +1 -0
  26. package/components/chat-independent/index.mjs +105 -212
  27. package/components/chat-independent/src/index.vue.d.ts +20 -2712
  28. package/components/components.css +1 -0
  29. package/components/drawer/index.cjs +1 -0
  30. package/components/drawer/index.mjs +53 -94
  31. package/components/drawer/src/ctx.d.ts +22 -22
  32. package/components/drawer/src/index.vue.d.ts +84 -557
  33. package/components/index.cjs +1 -0
  34. package/components/index.d.ts +1 -0
  35. package/components/lottie-animation/index.cjs +1 -0
  36. package/components/lottie-animation/index.mjs +36 -55
  37. package/components/lottie-animation/src/index.vue.d.ts +3 -2
  38. package/components/metahuman-broadcasting/index.cjs +1 -0
  39. package/components/metahuman-broadcasting/index.mjs +89 -140
  40. package/components/metahuman-broadcasting/src/index.vue.d.ts +16 -718
  41. package/components/monaco-editor/index.cjs +1 -0
  42. package/components/monaco-editor/index.mjs +75 -73
  43. package/components/monaco-editor/src/ctx.d.ts +10 -4
  44. package/components/monaco-editor/src/index.vue.d.ts +17 -2
  45. package/components/monaco-environment/index.cjs +1 -0
  46. package/components/monaco-environment/index.mjs +23 -38
  47. package/components/monaco-environment/src/index.vue.d.ts +2 -1
  48. package/components/pixi-frame/index.cjs +1 -0
  49. package/components/pixi-frame/index.mjs +501 -1978
  50. package/components/pixi-frame/src/apng.vue.d.ts +17 -73
  51. package/components/pixi-frame/src/bitmap-generator.vue.d.ts +24 -66
  52. package/components/pixi-frame/src/bitmap.vue.d.ts +28 -80
  53. package/components/pixi-frame/src/buffer-image.vue.d.ts +29 -97
  54. package/components/pixi-frame/src/core.vue.d.ts +20 -75
  55. package/components/pixi-frame/src/index.vue.d.ts +302 -237
  56. package/components/pixi-frame/src/provider.vue.d.ts +12 -1
  57. package/components/pixi-frame/src/video.vue.d.ts +17 -71
  58. package/components/pixi-frame/src/view.vue.d.ts +4 -16
  59. package/components/recorder-button/index.cjs +1 -0
  60. package/components/recorder-button/index.mjs +140 -269
  61. package/components/recorder-button/src/index.vue.d.ts +67 -66
  62. package/components/routes-menu-content/index.cjs +1 -0
  63. package/components/routes-menu-content/index.mjs +150 -229
  64. package/components/routes-menu-content/src/index.vue.d.ts +27 -26
  65. package/components/routes-menu-content/src/item/core/index.vue.d.ts +27 -26
  66. package/components/routes-menu-content/src/item/index.vue.d.ts +27 -26
  67. package/components/scrollbar/index.cjs +1 -0
  68. package/components/scrollbar/index.mjs +288 -567
  69. package/components/scrollbar/src/bar.vue.d.ts +6 -133
  70. package/components/scrollbar/src/index.vue.d.ts +66 -337
  71. package/components/scrollbar/src/thumb.vue.d.ts +3 -80
  72. package/components/sender/index.cjs +1 -0
  73. package/components/sender/index.mjs +156 -285
  74. package/components/sender/src/SenderHeader.vue.d.ts +14 -221
  75. package/components/sender/src/index.vue.d.ts +16 -505
  76. package/components/speech-button/index.cjs +1 -0
  77. package/components/speech-button/index.mjs +98 -144
  78. package/components/speech-button/src/LoadingIcon.vue.d.ts +2 -1
  79. package/components/speech-button/src/RecordingIcon.vue.d.ts +2 -1
  80. package/components/speech-button/src/index.vue.d.ts +6 -5
  81. package/components/table-columns/index.cjs +1 -0
  82. package/components/table-columns/index.mjs +48 -78
  83. package/components/table-columns/src/ctx.d.ts +12 -12
  84. package/components/table-columns/src/el-ctx.d.ts +3 -3
  85. package/components/table-columns/src/index.vue.d.ts +28 -27
  86. package/components/tables-v1/index.cjs +1 -0
  87. package/components/tables-v1/index.mjs +99 -160
  88. package/components/tables-v1/src/ctx.d.ts +38 -38
  89. package/components/tables-v1/src/el-ctx.d.ts +7 -7
  90. package/components/tables-v1/src/index.vue.d.ts +111 -2266
  91. package/components/tables-v1-checkbox/index.cjs +1 -0
  92. package/components/tables-v1-checkbox/index.mjs +116 -4043
  93. package/components/tables-v1-checkbox/src/ctx.d.ts +36 -36
  94. package/components/tables-v1-checkbox/src/index.vue.d.ts +224 -2378
  95. package/components/text/index.cjs +1 -0
  96. package/components/text/index.mjs +70 -108
  97. package/components/text/src/ctx.d.ts +32 -32
  98. package/components/text/src/index.vue.d.ts +92 -1819
  99. package/components/thinking/index.cjs +1 -0
  100. package/components/thinking/index.mjs +127 -227
  101. package/components/thinking/src/index.vue.d.ts +23 -2045
  102. package/components/typing-markdown/index.cjs +1 -0
  103. package/components/typing-markdown/index.mjs +61 -201
  104. package/components/typing-markdown/src/index.vue.d.ts +3 -2
  105. package/components/vditor/index.cjs +1 -0
  106. package/components/vditor/index.mjs +121 -195
  107. package/components/vditor/src/ctx.d.ts +2 -2
  108. package/components/vditor/src/handle-fullscreen.vue.d.ts +3 -2
  109. package/components/vditor/src/handle-value.vue.d.ts +3 -2
  110. package/components/vditor/src/index.vue.d.ts +5 -4
  111. package/components/xgplayer/index.cjs +1 -0
  112. package/components/xgplayer/index.mjs +49 -90
  113. package/components/xgplayer/src/core.vue.d.ts +13 -18
  114. package/components/xgplayer/src/index.vue.d.ts +13 -67
  115. package/composables/el-breakpoints/index.cjs +1 -0
  116. package/composables/el-breakpoints/index.d.ts +10 -10
  117. package/composables/el-breakpoints/index.mjs +10 -12
  118. package/composables/index.cjs +1 -0
  119. package/composables/index.d.ts +1 -0
  120. package/composables/recorder/index.cjs +1 -0
  121. package/composables/recorder/index.mjs +9172 -14803
  122. package/element/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  123. package/element/bubble/index.cjs +3 -0
  124. package/element/bubble/index.d.ts +1 -1
  125. package/element/bubble/index.mjs +1 -1
  126. package/element/bubble/src/index.vue.d.ts +22 -22
  127. package/element/index.css +1 -1
  128. package/element/thinking/index.cjs +1 -0
  129. package/element/thinking/index.d.ts +1 -1
  130. package/element/thinking/index.mjs +1 -1
  131. package/element/thinking/src/index.vue.d.ts +26 -26
  132. package/element/thinking/src/types.d.ts +10 -0
  133. package/icons/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  134. package/icons/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
  135. package/icons/end/index.cjs +1 -0
  136. package/icons/end/index.mjs +21 -26
  137. package/icons/end/src/index.vue.d.ts +3 -0
  138. package/icons/keyboard/index.cjs +1 -0
  139. package/icons/keyboard/index.mjs +21 -26
  140. package/icons/keyboard/src/index.vue.d.ts +3 -0
  141. package/icons/start/index.cjs +1 -0
  142. package/icons/start/index.mjs +21 -26
  143. package/icons/start/src/index.vue.d.ts +3 -0
  144. package/icons/voice/index.cjs +1 -0
  145. package/icons/voice/index.mjs +26 -44
  146. package/icons/voice/src/index.vue.d.ts +2 -3
  147. package/index.css +2 -558
  148. package/index.d.ts +1 -0
  149. package/package.json +78 -87
  150. package/shared/data/index.cjs +1 -0
  151. package/shared/data/index.mjs +16 -22
  152. package/shared/types/index.cjs +1 -0
  153. package/shared/types/index.d.ts +1 -0
  154. package/components/LinkOutlined.mjs +0 -1321
  155. package/components/_commonjsHelpers.mjs +0 -7
  156. package/components/_plugin-vue_export-helper.mjs +0 -9
  157. package/components/bubble-list/index.css +0 -70
  158. package/components/bubble-templates/index.css +0 -4
  159. package/components/chat-independent/index.css +0 -47
  160. package/components/drawer/index.css +0 -124
  161. package/components/index2.mjs +0 -78
  162. package/components/lottie-animation/index.css +0 -4
  163. package/components/monaco-editor/index.css +0 -4
  164. package/components/pixi-frame/index.css +0 -4
  165. package/components/recorder-button/index.css +0 -69
  166. package/components/sender/index.css +0 -22
  167. package/components/speech-button/index.css +0 -10
  168. package/components/tables-v1/index.css +0 -7
  169. package/components/tables-v1-checkbox/index.css +0 -8
  170. package/components/thinking/index.css +0 -125
  171. package/components/typing-markdown/index.css +0 -31
  172. package/components/vditor/index.css +0 -12
  173. package/components/xgplayer/index.css +0 -1
  174. package/icons/_plugin-vue_export-helper.mjs +0 -9
@@ -1,2 +1,13 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
1
+ declare var __VLS_1: {};
2
+ type __VLS_Slots = {} & {
3
+ default?: (props: typeof __VLS_1) => any;
4
+ };
5
+ declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
7
+ declare const _default: typeof __VLS_export;
2
8
  export default _default;
9
+ type __VLS_WithSlots<T, S> = T & {
10
+ new (): {
11
+ $slots: S;
12
+ };
13
+ };
@@ -1,6 +1,9 @@
1
- import type { Texture } from 'pixi.js';
2
1
  import { TickerStatus } from '@vunk/shared/enum';
3
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ declare var __VLS_1: {};
3
+ type __VLS_Slots = {} & {
4
+ default?: (props: typeof __VLS_1) => any;
5
+ };
6
+ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
7
  url: {
5
8
  type: StringConstructor;
6
9
  required: true;
@@ -37,74 +40,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
37
40
  type: BooleanConstructor;
38
41
  default: boolean;
39
42
  };
40
- }>, {
41
- props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
42
- url: {
43
- type: StringConstructor;
44
- required: true;
45
- };
46
- data: {
47
- type: import("vue").PropType<any[]>;
48
- default: () => never[];
49
- };
50
- loop: {
51
- type: BooleanConstructor;
52
- default: boolean;
53
- };
54
- status: {
55
- type: import("vue").PropType<TickerStatus>;
56
- default: TickerStatus;
57
- };
58
- frameRate: {
59
- type: NumberConstructor;
60
- default: number;
61
- };
62
- label: {
63
- type: StringConstructor;
64
- default: string;
65
- };
66
- resize: {
67
- type: import("vue").PropType<import("./types").Resize>;
68
- default: undefined;
69
- };
70
- prerender: {
71
- type: BooleanConstructor;
72
- default: boolean;
73
- };
74
- visible: {
75
- type: BooleanConstructor;
76
- default: boolean;
77
- };
78
- }>> & Readonly<{
79
- "onUpdate:status"?: ((...args: any[]) => any) | undefined;
80
- onSetData?: ((...args: any[]) => any) | undefined;
81
- "onUpdate:data"?: ((...args: any[]) => any) | undefined;
82
- }> & {}>;
83
- emit: ((event: "update:status", ...args: any[]) => void) & ((event: "setData", ...args: any[]) => void) & ((event: "update:data", ...args: any[]) => void);
84
- compId: string;
85
- getAlias: () => string;
86
- sprite: import("pixi.js").Sprite;
87
- resizeSprite: () => void;
88
- texture: import("vue").Ref<Texture<import("pixi.js").TextureSource<any>> | undefined, Texture<import("pixi.js").TextureSource<any>> | undefined>;
89
- video: import("vue").ComputedRef<HTMLVideoElement | null>;
90
- readyDef: {
91
- _ref: import("vue").ShallowRef<unknown, unknown>;
92
- readonly value: unknown;
93
- promise: Promise<unknown>;
94
- resolve: import("@vunk/core").AnyFunc;
95
- reject: (reason?: any) => void;
96
- };
97
- videoError: import("vue").Ref<string, string>;
98
- loadVideoTexture: (url: string) => Promise<any>;
99
- setupVideoEvents: (video: HTMLVideoElement) => void;
100
- cleanupVideo: () => Promise<void>;
101
- play: () => void;
102
- pause: () => void;
103
- stop: () => void;
104
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
105
- 'update:status': null;
106
- 'update:data': null;
107
- setData: null;
43
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
44
+ "update:status": (...args: any[]) => void;
45
+ setData: (...args: any[]) => void;
46
+ "update:data": (...args: any[]) => void;
108
47
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
109
48
  url: {
110
49
  type: StringConstructor;
@@ -148,12 +87,19 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
148
87
  "onUpdate:data"?: ((...args: any[]) => any) | undefined;
149
88
  }>, {
150
89
  data: any[];
151
- visible: boolean;
152
90
  resize: import("./types").Resize;
91
+ visible: boolean;
153
92
  label: string;
154
93
  status: TickerStatus;
155
94
  prerender: boolean;
156
95
  loop: boolean;
157
96
  frameRate: number;
158
97
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
98
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
99
+ declare const _default: typeof __VLS_export;
159
100
  export default _default;
101
+ type __VLS_WithSlots<T, S> = T & {
102
+ new (): {
103
+ $slots: S;
104
+ };
105
+ };
@@ -1,24 +1,11 @@
1
1
  import type { ApplicationOptions } from 'pixi.js';
2
- import type { PropType, Ref } from 'vue';
3
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ import type { PropType } from 'vue';
3
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
4
  defaultOptions: {
5
5
  type: PropType<Partial<ApplicationOptions>>;
6
6
  default: () => {};
7
7
  };
8
- }>, {
9
- props: import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
10
- defaultOptions: {
11
- type: PropType<Partial<ApplicationOptions>>;
12
- default: () => {};
13
- };
14
- }>> & Readonly<{}> & {}>;
15
- app: import("pixi.js").Application<import("pixi.js").Renderer>;
16
- context: {
17
- whenDef: import("@vunk/shared/promise").Deferred<import("pixi.js").Application>;
18
- when: () => Promise<import("pixi.js").Application>;
19
- };
20
- appRef: Ref<HTMLDivElement, HTMLDivElement>;
21
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
8
+ }>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
22
9
  defaultOptions: {
23
10
  type: PropType<Partial<ApplicationOptions>>;
24
11
  default: () => {};
@@ -26,4 +13,5 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
26
13
  }>> & Readonly<{}>, {
27
14
  defaultOptions: Partial<ApplicationOptions>;
28
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
16
+ declare const _default: typeof __VLS_export;
29
17
  export default _default;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F=require("@vunk/plus/composables/recorder"),_=require("element-plus"),e=require("vue"),S=require("../_plugin-vue_export-helper-BHFhmbuH.js"),C={onTextZone:{type:Function,default:void 0},appendTo:{type:null,default:"body"},disabled:{type:Boolean,default:!1},speechToText:{type:Function,default:void 0},submitToText:{type:Boolean,default:!1}},L={submitText:t=>typeof t=="string",submit:t=>!0,error:t=>!0};async function M(t,s){const u=new FormData;u.append("file",s,"audio.wav");const l=await fetch(t,{method:"POST",body:u});if(!l.ok)throw new Error("Speech to text failed");return(await l.json()).text}const O=100,Z=e.defineComponent({name:"VkRecorderButton",components:{ElButton:_.ElButton},props:C,emits:L,setup(t,{emit:s}){const u=e.ref(),{openOrStart:l,recording:a,recorder:d,wave:g}=F.useRecorder({waveViewRef:u,defaultOptions:{onProcess:k}}),m=e.ref("");let D=null;const c=e.ref(!1),y=async()=>{try{await l({openThen:()=>(c.value=!1,!1)})}catch(n){console.error("录音失败:",n),s("error",n),c.value=!1;return}a.value=!0},w=e.ref({x:0,y:0}),v=e.ref(!1),f=e.ref(!1);let E=!1;const V=()=>{const n=f.value;d.stop(async o=>{if(m.value=(window.URL||webkitURL).createObjectURL(o),d.close(),a.value=!1,s("submit",{blob:o,url:m.value}),n||t.submitToText)if(t.onTextZone)t.onTextZone({blob:o,url:m.value});else{if(t.speechToText){t.speechToText(o).then(r=>{s("submitText",r)});return}M("/speech-to-text",o).then(r=>{s("submitText",r)}).catch(r=>{console.error("语音识别错误:",r),_.ElMessage.error("转换文字失败")})}})},N=()=>{document.addEventListener("mousemove",b),document.addEventListener("mouseup",x)},B=()=>{document.removeEventListener("mousemove",b),document.removeEventListener("mouseup",x)},R=n=>{if(t.disabled)return;n.preventDefault(),E=!0;const o="touches"in n?n.touches[0]:n;w.value={x:o.clientX,y:o.clientY},n instanceof MouseEvent&&N(),D=setTimeout(()=>{E&&(c.value=!0,y())},O)};function b(n){if(n.preventDefault(),!c.value)return;const o="touches"in n?n.touches[0]:n;w.value={x:o.clientX,y:o.clientY};const r=document.querySelector(".cancel-btn-x"),p=document.querySelector(".text-btn-x");if(r&&p){const T=r.getBoundingClientRect(),h=p.getBoundingClientRect();v.value=o.clientX>=T.left&&o.clientX<=T.right&&o.clientY>=T.top&&o.clientY<=T.bottom,f.value=o.clientX>=h.left&&o.clientX<=h.right&&o.clientY>=h.top&&o.clientY<=h.bottom}}function x(n){E=!1,clearTimeout(D),c.value&&(v.value?d.close():V(),c.value=!1,v.value=!1,f.value=!1),n instanceof MouseEvent&&B()}function k(n,o,r,p){g.value?.input(n[n.length-1],o,p)}return e.onUnmounted(()=>{B()}),{onmousedown:R,onmousemove:b,onmouseup:x,recording:a,recordingNode:u,blobUrl:m,isDragging:c,cancelZone:v,isTextZone:f}}}),P={class:"vk-recorder-container"},q={class:"vk-recording-mask"},U={class:"recording-tip"},X={ref:"recordingNode",class:"wave-container"},Y={class:"tip-text"},$={class:"action-buttons"},j={class:"cancel-btn-x"},z={class:"text-btn-x"};function A(t,s,u,l,a,d){const g=e.resolveComponent("ElButton");return e.openBlock(),e.createElementBlock("div",P,[(e.openBlock(),e.createBlock(e.Teleport,{to:t.appendTo},[e.withDirectives(e.createElementVNode("div",q,[e.createElementVNode("div",U,[e.createElementVNode("div",X,null,512),e.createElementVNode("div",Y,e.toDisplayString(t.cancelZone?"松开手指,取消发送":"松开发送,上滑取消"),1)]),e.createElementVNode("div",$,[e.createElementVNode("div",j,[e.createElementVNode("div",{class:e.normalizeClass(["cancel-btn",{active:t.cancelZone}])},s[0]||(s[0]=[e.createElementVNode("div",{class:"btn-icon"}," × ",-1),e.createElementVNode("div",{class:"btn-text"}," 取消发送 ",-1)]),2)]),e.createElementVNode("div",z,[e.createElementVNode("div",{class:e.normalizeClass(["text-btn",{active:t.isTextZone}])},s[1]||(s[1]=[e.createElementVNode("div",{class:"btn-icon"}," 文 ",-1),e.createElementVNode("div",{class:"btn-text"}," 转为文字 ",-1)]),2)])])],512),[[e.vShow,t.isDragging]])],8,["to"])),e.createVNode(g,e.mergeProps(t.$attrs,{disabled:t.disabled,class:["vk-recorder-button",{"is-recording":t.recording}],size:"large",onTouchstart:t.onmousedown,onTouchmove:t.onmousemove,onTouchend:t.onmouseup,onMousedown:t.onmousedown}),{default:e.withCtx(()=>s[2]||(s[2]=[e.createElementVNode("span",{class:"vk-recorder-button-text"},"按住 说话",-1)])),_:1},16,["disabled","class","onTouchstart","onTouchmove","onTouchend","onMousedown"])])}const i=S._export_sfc(Z,[["render",A]]),G=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));i.install=t=>{t.component(i.name||"VkRecorderButton",i)};exports.VkRecorderButton=i;exports.__VkRecorderButton=G;exports.default=i;
@@ -1,9 +1,8 @@
1
- import { useRecorder } from '@vunk/plus/composables/recorder';
2
- import { ElButton, ElMessage } from 'element-plus';
3
- import { defineComponent, ref, onUnmounted, resolveComponent, openBlock, createElementBlock, createCommentVNode, createBlock, Teleport, withDirectives, createElementVNode, toDisplayString, normalizeClass, vShow, createVNode, mergeProps, withCtx } from 'vue';
4
- import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
5
-
6
- const props = {
1
+ import { useRecorder as Z } from "@vunk/plus/composables/recorder";
2
+ import { ElButton as O, ElMessage as M } from "element-plus";
3
+ import { defineComponent as V, ref as i, onUnmounted as N, resolveComponent as P, createElementBlock as U, openBlock as E, createBlock as X, createVNode as Y, Teleport as $, withDirectives as j, createElementVNode as n, toDisplayString as z, normalizeClass as R, vShow as A, mergeProps as q, withCtx as G } from "vue";
4
+ import { _ as I } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
5
+ const H = {
7
6
  /**
8
7
  * 自定义转为文本区域事件
9
8
  */
@@ -20,7 +19,7 @@ const props = {
20
19
  },
21
20
  disabled: {
22
21
  type: Boolean,
23
- default: false
22
+ default: !1
24
23
  },
25
24
  /**
26
25
  * 语音转文本函数
@@ -34,315 +33,187 @@ const props = {
34
33
  */
35
34
  submitToText: {
36
35
  type: Boolean,
37
- default: false
36
+ default: !1
38
37
  }
38
+ }, J = {
39
+ submitText: (e) => typeof e == "string",
40
+ submit: (e) => !0,
41
+ error: (e) => !0
39
42
  };
40
- const emits = {
41
- submitText: (text) => typeof text === "string",
42
- submit: (_) => true,
43
- error: (_) => true
44
- };
45
-
46
- async function speechToText(url, blob) {
47
- const formData = new FormData();
48
- formData.append("file", blob, "audio.wav");
49
- const response = await fetch(url, {
43
+ async function K(e, s) {
44
+ const r = new FormData();
45
+ r.append("file", s, "audio.wav");
46
+ const a = await fetch(e, {
50
47
  method: "POST",
51
- body: formData
48
+ body: r
52
49
  });
53
- if (!response.ok) {
50
+ if (!a.ok)
54
51
  throw new Error("Speech to text failed");
55
- }
56
- const result = await response.json();
57
- return result.text;
52
+ return (await a.json()).text;
58
53
  }
59
-
60
- const LONG_PRESS_DURATION = 100;
61
- var _sfc_main = defineComponent({
54
+ const Q = 100, W = V({
62
55
  name: "VkRecorderButton",
63
56
  components: {
64
- ElButton
57
+ ElButton: O
65
58
  },
66
- props,
67
- emits,
68
- setup(props2, { emit }) {
69
- const recordingNode = ref();
70
- const { openOrStart, recording, recorder, wave } = useRecorder({
71
- waveViewRef: recordingNode,
59
+ props: H,
60
+ emits: J,
61
+ setup(e, { emit: s }) {
62
+ const r = i(), { openOrStart: a, recording: l, recorder: d, wave: g } = Z({
63
+ waveViewRef: r,
72
64
  defaultOptions: {
73
- onProcess
65
+ onProcess: C
74
66
  }
75
- });
76
- const blobUrl = ref("");
77
- let pressTimer = null;
78
- const isDragging = ref(false);
79
- const startRecording = async () => {
67
+ }), v = i("");
68
+ let y = null;
69
+ const c = i(!1), k = async () => {
80
70
  try {
81
- await openOrStart({
71
+ await a({
82
72
  // 授权时, 取消弹窗
83
- openThen: () => {
84
- isDragging.value = false;
85
- return false;
86
- }
73
+ openThen: () => (c.value = !1, !1)
87
74
  });
88
- } catch (e) {
89
- console.error("\u5F55\u97F3\u5931\u8D25:", e);
90
- emit("error", e);
91
- isDragging.value = false;
75
+ } catch (o) {
76
+ console.error("录音失败:", o), s("error", o), c.value = !1;
92
77
  return;
93
78
  }
94
- recording.value = true;
95
- };
96
- const dragPosition = ref({ x: 0, y: 0 });
97
- const cancelZone = ref(false);
98
- const isTextZone = ref(false);
99
- let isMouseDown = false;
100
- const stopRecording = () => {
101
- const theTextZone = isTextZone.value;
102
- recorder.stop(async (blob) => {
103
- blobUrl.value = (window.URL || webkitURL).createObjectURL(blob);
104
- recorder.close();
105
- recording.value = false;
106
- emit("submit", {
107
- blob,
108
- url: blobUrl.value
109
- });
110
- if (theTextZone || props2.submitToText) {
111
- if (props2.onTextZone) {
112
- props2.onTextZone({
113
- blob,
114
- url: blobUrl.value
79
+ l.value = !0;
80
+ }, B = i({ x: 0, y: 0 }), m = i(!1), f = i(!1);
81
+ let b = !1;
82
+ const F = () => {
83
+ const o = f.value;
84
+ d.stop(async (t) => {
85
+ if (v.value = (window.URL || webkitURL).createObjectURL(t), d.close(), l.value = !1, s("submit", {
86
+ blob: t,
87
+ url: v.value
88
+ }), o || e.submitToText)
89
+ if (e.onTextZone)
90
+ e.onTextZone({
91
+ blob: t,
92
+ url: v.value
115
93
  });
116
- } else {
117
- if (props2.speechToText) {
118
- props2.speechToText(blob).then((text) => {
119
- emit("submitText", text);
94
+ else {
95
+ if (e.speechToText) {
96
+ e.speechToText(t).then((u) => {
97
+ s("submitText", u);
120
98
  });
121
99
  return;
122
100
  }
123
- speechToText("/speech-to-text", blob).then((text) => {
124
- emit("submitText", text);
125
- }).catch((err) => {
126
- console.error("\u8BED\u97F3\u8BC6\u522B\u9519\u8BEF:", err);
127
- ElMessage.error("\u8F6C\u6362\u6587\u5B57\u5931\u8D25");
101
+ K("/speech-to-text", t).then((u) => {
102
+ s("submitText", u);
103
+ }).catch((u) => {
104
+ console.error("语音识别错误:", u), M.error("转换文字失败");
128
105
  });
129
106
  }
130
- }
131
107
  });
132
- };
133
- const addDocumentListeners = () => {
134
- document.addEventListener("mousemove", onmousemove);
135
- document.addEventListener("mouseup", onmouseup);
136
- };
137
- const removeDocumentListeners = () => {
138
- document.removeEventListener("mousemove", onmousemove);
139
- document.removeEventListener("mouseup", onmouseup);
140
- };
141
- const onmousedown = (e) => {
142
- if (props2.disabled)
108
+ }, S = () => {
109
+ document.addEventListener("mousemove", x), document.addEventListener("mouseup", D);
110
+ }, _ = () => {
111
+ document.removeEventListener("mousemove", x), document.removeEventListener("mouseup", D);
112
+ }, L = (o) => {
113
+ if (e.disabled)
143
114
  return;
144
- e.preventDefault();
145
- isMouseDown = true;
146
- const touch = "touches" in e ? e.touches[0] : e;
147
- dragPosition.value = { x: touch.clientX, y: touch.clientY };
148
- if (e instanceof MouseEvent) {
149
- addDocumentListeners();
150
- }
151
- pressTimer = setTimeout(() => {
152
- if (isMouseDown) {
153
- isDragging.value = true;
154
- startRecording();
155
- }
156
- }, LONG_PRESS_DURATION);
115
+ o.preventDefault(), b = !0;
116
+ const t = "touches" in o ? o.touches[0] : o;
117
+ B.value = { x: t.clientX, y: t.clientY }, o instanceof MouseEvent && S(), y = setTimeout(() => {
118
+ b && (c.value = !0, k());
119
+ }, Q);
157
120
  };
158
- function onmousemove(e) {
159
- e.preventDefault();
160
- if (!isDragging.value)
121
+ function x(o) {
122
+ if (o.preventDefault(), !c.value)
161
123
  return;
162
- const touch = "touches" in e ? e.touches[0] : e;
163
- dragPosition.value = { x: touch.clientX, y: touch.clientY };
164
- const cancelBtn = document.querySelector(".cancel-btn-x");
165
- const textBtn = document.querySelector(".text-btn-x");
166
- if (cancelBtn && textBtn) {
167
- const cancelRect = cancelBtn.getBoundingClientRect();
168
- const textRect = textBtn.getBoundingClientRect();
169
- cancelZone.value = touch.clientX >= cancelRect.left && touch.clientX <= cancelRect.right && touch.clientY >= cancelRect.top && touch.clientY <= cancelRect.bottom;
170
- isTextZone.value = touch.clientX >= textRect.left && touch.clientX <= textRect.right && touch.clientY >= textRect.top && touch.clientY <= textRect.bottom;
124
+ const t = "touches" in o ? o.touches[0] : o;
125
+ B.value = { x: t.clientX, y: t.clientY };
126
+ const u = document.querySelector(".cancel-btn-x"), p = document.querySelector(".text-btn-x");
127
+ if (u && p) {
128
+ const T = u.getBoundingClientRect(), h = p.getBoundingClientRect();
129
+ m.value = t.clientX >= T.left && t.clientX <= T.right && t.clientY >= T.top && t.clientY <= T.bottom, f.value = t.clientX >= h.left && t.clientX <= h.right && t.clientY >= h.top && t.clientY <= h.bottom;
171
130
  }
172
131
  }
173
- function onmouseup(e) {
174
- isMouseDown = false;
175
- clearTimeout(pressTimer);
176
- if (isDragging.value) {
177
- if (cancelZone.value) {
178
- recorder.close();
179
- } else {
180
- stopRecording();
181
- }
182
- isDragging.value = false;
183
- cancelZone.value = false;
184
- isTextZone.value = false;
185
- }
186
- if (e instanceof MouseEvent) {
187
- removeDocumentListeners();
188
- }
132
+ function D(o) {
133
+ b = !1, clearTimeout(y), c.value && (m.value ? d.close() : F(), c.value = !1, m.value = !1, f.value = !1), o instanceof MouseEvent && _();
189
134
  }
190
- function onProcess(buffers, powerLevel, bufferDuration, bufferSampleRate) {
191
- wave.value?.input(
192
- buffers[buffers.length - 1],
193
- powerLevel,
194
- bufferSampleRate
135
+ function C(o, t, u, p) {
136
+ g.value?.input(
137
+ o[o.length - 1],
138
+ t,
139
+ p
195
140
  );
196
141
  }
197
- onUnmounted(() => {
198
- removeDocumentListeners();
199
- });
200
- return {
201
- onmousedown,
202
- onmousemove,
203
- onmouseup,
204
- recording,
205
- recordingNode,
206
- blobUrl,
207
- isDragging,
208
- cancelZone,
209
- isTextZone
142
+ return N(() => {
143
+ _();
144
+ }), {
145
+ onmousedown: L,
146
+ onmousemove: x,
147
+ onmouseup: D,
148
+ recording: l,
149
+ recordingNode: r,
150
+ blobUrl: v,
151
+ isDragging: c,
152
+ cancelZone: m,
153
+ isTextZone: f
210
154
  };
211
155
  }
212
- });
213
-
214
- const _hoisted_1 = { class: "vk-recorder-container" };
215
- const _hoisted_2 = { class: "vk-recording-mask" };
216
- const _hoisted_3 = { class: "recording-tip" };
217
- const _hoisted_4 = {
156
+ }), ee = { class: "vk-recorder-container" }, te = { class: "vk-recording-mask" }, oe = { class: "recording-tip" }, ne = {
218
157
  ref: "recordingNode",
219
158
  class: "wave-container"
220
- };
221
- const _hoisted_5 = { class: "tip-text" };
222
- const _hoisted_6 = { class: "action-buttons" };
223
- const _hoisted_7 = { class: "cancel-btn-x" };
224
- const _hoisted_8 = { class: "text-btn-x" };
225
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
226
- const _component_ElButton = resolveComponent("ElButton");
227
- return openBlock(), createElementBlock("div", _hoisted_1, [
228
- createCommentVNode(" \u906E\u7F69\u5C42 "),
229
- (openBlock(), createBlock(Teleport, { to: _ctx.appendTo }, [
230
- withDirectives(createElementVNode(
231
- "div",
232
- _hoisted_2,
233
- [
234
- createCommentVNode(" \u5F55\u97F3\u63D0\u793A\u533A\u57DF\u79FB\u5230\u4E0A\u9762 "),
235
- createElementVNode("div", _hoisted_3, [
236
- createElementVNode(
237
- "div",
238
- _hoisted_4,
239
- null,
240
- 512
241
- /* NEED_PATCH */
242
- ),
243
- createElementVNode(
244
- "div",
245
- _hoisted_5,
246
- toDisplayString(_ctx.cancelZone ? "\u677E\u5F00\u624B\u6307\uFF0C\u53D6\u6D88\u53D1\u9001" : "\u677E\u5F00\u53D1\u9001\uFF0C\u4E0A\u6ED1\u53D6\u6D88"),
247
- 1
248
- /* TEXT */
249
- )
159
+ }, se = { class: "tip-text" }, ue = { class: "action-buttons" }, ce = { class: "cancel-btn-x" }, re = { class: "text-btn-x" };
160
+ function ie(e, s, r, a, l, d) {
161
+ const g = P("ElButton");
162
+ return E(), U("div", ee, [
163
+ (E(), X($, { to: e.appendTo }, [
164
+ j(n("div", te, [
165
+ n("div", oe, [
166
+ n("div", ne, null, 512),
167
+ n("div", se, z(e.cancelZone ? "松开手指,取消发送" : "松开发送,上滑取消"), 1)
168
+ ]),
169
+ n("div", ue, [
170
+ n("div", ce, [
171
+ n("div", {
172
+ class: R(["cancel-btn", { active: e.cancelZone }])
173
+ }, s[0] || (s[0] = [
174
+ n("div", { class: "btn-icon" }, " × ", -1),
175
+ n("div", { class: "btn-text" }, " 取消发送 ", -1)
176
+ ]), 2)
250
177
  ]),
251
- createElementVNode("div", _hoisted_6, [
252
- createElementVNode("div", _hoisted_7, [
253
- createElementVNode(
254
- "div",
255
- {
256
- class: normalizeClass(["cancel-btn", { active: _ctx.cancelZone }])
257
- },
258
- _cache[0] || (_cache[0] = [
259
- createElementVNode(
260
- "div",
261
- { class: "btn-icon" },
262
- " \xD7 ",
263
- -1
264
- /* HOISTED */
265
- ),
266
- createElementVNode(
267
- "div",
268
- { class: "btn-text" },
269
- " \u53D6\u6D88\u53D1\u9001 ",
270
- -1
271
- /* HOISTED */
272
- )
273
- ]),
274
- 2
275
- /* CLASS */
276
- )
277
- ]),
278
- createElementVNode("div", _hoisted_8, [
279
- createElementVNode(
280
- "div",
281
- {
282
- class: normalizeClass(["text-btn", { active: _ctx.isTextZone }])
283
- },
284
- _cache[1] || (_cache[1] = [
285
- createElementVNode(
286
- "div",
287
- { class: "btn-icon" },
288
- " \u6587 ",
289
- -1
290
- /* HOISTED */
291
- ),
292
- createElementVNode(
293
- "div",
294
- { class: "btn-text" },
295
- " \u8F6C\u4E3A\u6587\u5B57 ",
296
- -1
297
- /* HOISTED */
298
- )
299
- ]),
300
- 2
301
- /* CLASS */
302
- )
303
- ])
178
+ n("div", re, [
179
+ n("div", {
180
+ class: R(["text-btn", { active: e.isTextZone }])
181
+ }, s[1] || (s[1] = [
182
+ n("div", { class: "btn-icon" }, " 文 ", -1),
183
+ n("div", { class: "btn-text" }, " 转为文字 ", -1)
184
+ ]), 2)
304
185
  ])
305
- ],
306
- 512
307
- /* NEED_PATCH */
308
- ), [
309
- [vShow, _ctx.isDragging]
186
+ ])
187
+ ], 512), [
188
+ [A, e.isDragging]
310
189
  ])
311
190
  ], 8, ["to"])),
312
- createCommentVNode(" \u5F55\u97F3\u6309\u94AE "),
313
- createVNode(_component_ElButton, mergeProps(_ctx.$attrs, {
314
- disabled: _ctx.disabled,
191
+ Y(g, q(e.$attrs, {
192
+ disabled: e.disabled,
315
193
  class: ["vk-recorder-button", {
316
- "is-recording": _ctx.recording
194
+ "is-recording": e.recording
317
195
  }],
318
196
  size: "large",
319
- onTouchstart: _ctx.onmousedown,
320
- onTouchmove: _ctx.onmousemove,
321
- onTouchend: _ctx.onmouseup,
322
- onMousedown: _ctx.onmousedown
197
+ onTouchstart: e.onmousedown,
198
+ onTouchmove: e.onmousemove,
199
+ onTouchend: e.onmouseup,
200
+ onMousedown: e.onmousedown
323
201
  }), {
324
- default: withCtx(() => _cache[2] || (_cache[2] = [
325
- createElementVNode(
326
- "span",
327
- { class: "vk-recorder-button-text" },
328
- "\u6309\u4F4F \u8BF4\u8BDD",
329
- -1
330
- /* HOISTED */
331
- )
202
+ default: G(() => s[2] || (s[2] = [
203
+ n("span", { class: "vk-recorder-button-text" }, "按住 说话", -1)
332
204
  ])),
333
205
  _: 1
334
- /* STABLE */
335
206
  }, 16, ["disabled", "class", "onTouchstart", "onTouchmove", "onTouchend", "onMousedown"])
336
207
  ]);
337
208
  }
338
- var VkRecorderButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/recorder-button/src/index.vue"]]);
339
-
340
- var types = /*#__PURE__*/Object.freeze({
209
+ const w = /* @__PURE__ */ I(W, [["render", ie]]), me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
341
210
  __proto__: null
342
- });
343
-
344
- VkRecorderButton.install = (app) => {
345
- app.component(VkRecorderButton.name || "VkRecorderButton", VkRecorderButton);
211
+ }, Symbol.toStringTag, { value: "Module" }));
212
+ w.install = (e) => {
213
+ e.component(w.name || "VkRecorderButton", w);
214
+ };
215
+ export {
216
+ w as VkRecorderButton,
217
+ me as __VkRecorderButton,
218
+ w as default
346
219
  };
347
-
348
- export { VkRecorderButton, types as __VkRecorderButton, VkRecorderButton as default };