@vunk/plus 1.12.2 → 1.13.1
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/components/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
- package/components/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
- package/components/agent-chat-provider/index.cjs +1 -0
- package/components/agent-chat-provider/index.mjs +113 -187
- package/components/agent-chat-provider/src/index.vue.d.ts +3 -2
- package/components/avatar/index.cjs +1 -0
- package/components/avatar/index.mjs +25 -31
- package/components/avatar/src/index.vue.d.ts +40 -39
- package/components/broadcasting-markdown/__tests__/const.test.d.ts +1 -0
- package/components/broadcasting-markdown/__tests__/utils.test.d.ts +1 -0
- package/components/broadcasting-markdown/index.cjs +5 -0
- package/components/broadcasting-markdown/index.mjs +346 -4376
- package/components/broadcasting-markdown/src/howler-speech.vue.d.ts +18 -24
- package/components/broadcasting-markdown/src/index.vue.d.ts +101 -51
- package/components/broadcasting-markdown/src/paragraph.vue.d.ts +17 -29
- package/components/broadcasting-markdown/src/speech-error.vue.d.ts +2 -59
- package/components/bubble-list/index.cjs +1 -0
- package/components/bubble-list/index.mjs +220 -302
- package/components/bubble-list/src/core/index.vue.d.ts +40 -885
- package/components/bubble-list/src/core/loading.vue.d.ts +3 -0
- package/components/bubble-list/src/index.vue.d.ts +29 -1321
- package/components/bubble-templates/index.cjs +1 -0
- package/components/bubble-templates/index.mjs +34 -49
- package/components/bubble-templates/src/index.vue.d.ts +3 -224
- package/components/chat-independent/index.cjs +1 -0
- package/components/chat-independent/index.mjs +105 -212
- package/components/chat-independent/src/index.vue.d.ts +20 -2712
- package/components/components.css +1 -0
- package/components/drawer/index.cjs +1 -0
- package/components/drawer/index.mjs +53 -94
- package/components/drawer/src/ctx.d.ts +22 -22
- package/components/drawer/src/index.vue.d.ts +84 -557
- package/components/index.cjs +1 -0
- package/components/index.d.ts +1 -0
- package/components/lottie-animation/index.cjs +1 -0
- package/components/lottie-animation/index.mjs +36 -55
- package/components/lottie-animation/src/index.vue.d.ts +3 -2
- package/components/metahuman-broadcasting/index.cjs +1 -0
- package/components/metahuman-broadcasting/index.mjs +89 -140
- package/components/metahuman-broadcasting/src/index.vue.d.ts +16 -718
- package/components/monaco-editor/index.cjs +1 -0
- package/components/monaco-editor/index.mjs +68 -95
- package/components/monaco-editor/src/index.vue.d.ts +3 -2
- package/components/monaco-environment/index.cjs +1 -0
- package/components/monaco-environment/index.mjs +23 -38
- package/components/monaco-environment/src/index.vue.d.ts +2 -1
- package/components/pixi-frame/index.cjs +1 -0
- package/components/pixi-frame/index.mjs +941 -1969
- package/components/pixi-frame/src/apng.vue.d.ts +17 -73
- package/components/pixi-frame/src/bitmap-generator.vue.d.ts +24 -66
- package/components/pixi-frame/src/bitmap.vue.d.ts +28 -80
- package/components/pixi-frame/src/buffer-image.vue.d.ts +29 -97
- package/components/pixi-frame/src/core.vue.d.ts +20 -75
- package/components/pixi-frame/src/index.vue.d.ts +302 -237
- package/components/pixi-frame/src/provider.vue.d.ts +12 -1
- package/components/pixi-frame/src/video.vue.d.ts +17 -71
- package/components/pixi-frame/src/view.vue.d.ts +4 -16
- package/components/recorder-button/index.cjs +1 -0
- package/components/recorder-button/index.mjs +140 -269
- package/components/recorder-button/src/index.vue.d.ts +67 -66
- package/components/routes-menu-content/index.cjs +1 -0
- package/components/routes-menu-content/index.mjs +150 -229
- package/components/routes-menu-content/src/index.vue.d.ts +27 -26
- package/components/routes-menu-content/src/item/core/index.vue.d.ts +27 -26
- package/components/routes-menu-content/src/item/index.vue.d.ts +27 -26
- package/components/scrollbar/index.cjs +1 -0
- package/components/scrollbar/index.mjs +288 -567
- package/components/scrollbar/src/bar.vue.d.ts +6 -133
- package/components/scrollbar/src/index.vue.d.ts +66 -337
- package/components/scrollbar/src/thumb.vue.d.ts +3 -80
- package/components/sender/index.cjs +1 -0
- package/components/sender/index.mjs +156 -285
- package/components/sender/src/SenderHeader.vue.d.ts +14 -221
- package/components/sender/src/index.vue.d.ts +16 -505
- package/components/speech-button/index.cjs +1 -0
- package/components/speech-button/index.mjs +98 -144
- package/components/speech-button/src/LoadingIcon.vue.d.ts +2 -1
- package/components/speech-button/src/RecordingIcon.vue.d.ts +2 -1
- package/components/speech-button/src/index.vue.d.ts +6 -5
- package/components/table-columns/index.cjs +1 -0
- package/components/table-columns/index.mjs +48 -78
- package/components/table-columns/src/ctx.d.ts +10 -10
- package/components/table-columns/src/el-ctx.d.ts +1 -1
- package/components/table-columns/src/index.vue.d.ts +24 -23
- package/components/tables-v1/index.cjs +1 -0
- package/components/tables-v1/index.mjs +99 -160
- package/components/tables-v1/src/ctx.d.ts +28 -28
- package/components/tables-v1/src/el-ctx.d.ts +2 -2
- package/components/tables-v1/src/index.vue.d.ts +88 -2243
- package/components/tables-v1-checkbox/index.cjs +98 -0
- package/components/tables-v1-checkbox/index.mjs +1594 -3735
- package/components/tables-v1-checkbox/src/ctx.d.ts +26 -26
- package/components/tables-v1-checkbox/src/index.vue.d.ts +176 -2330
- package/components/text/index.cjs +1 -0
- package/components/text/index.mjs +70 -108
- package/components/text/src/ctx.d.ts +31 -31
- package/components/text/src/index.vue.d.ts +92 -1819
- package/components/thinking/index.cjs +1 -0
- package/components/thinking/index.mjs +127 -227
- package/components/thinking/src/index.vue.d.ts +22 -2044
- package/components/typing-markdown/index.cjs +1 -0
- package/components/typing-markdown/index.mjs +61 -201
- package/components/typing-markdown/src/index.vue.d.ts +3 -2
- package/components/vditor/index.cjs +1 -0
- package/components/vditor/index.mjs +121 -195
- package/components/vditor/src/ctx.d.ts +2 -2
- package/components/vditor/src/handle-fullscreen.vue.d.ts +3 -2
- package/components/vditor/src/handle-value.vue.d.ts +3 -2
- package/components/vditor/src/index.vue.d.ts +5 -4
- package/components/xgplayer/index.cjs +1 -0
- package/components/xgplayer/index.mjs +49 -90
- package/components/xgplayer/src/core.vue.d.ts +13 -18
- package/components/xgplayer/src/index.vue.d.ts +13 -67
- package/composables/el-breakpoints/index.cjs +1 -0
- package/composables/el-breakpoints/index.d.ts +10 -10
- package/composables/el-breakpoints/index.mjs +10 -12
- package/composables/index.cjs +1 -0
- package/composables/index.d.ts +1 -0
- package/composables/recorder/index.cjs +1 -0
- package/composables/recorder/index.mjs +9172 -14803
- package/element/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
- package/element/bubble/index.cjs +3 -0
- package/element/bubble/index.d.ts +1 -1
- package/element/bubble/index.mjs +1 -1
- package/element/bubble/src/index.vue.d.ts +22 -22
- package/element/index.css +1 -1
- package/element/thinking/index.cjs +1 -0
- package/element/thinking/index.d.ts +1 -1
- package/element/thinking/index.mjs +1 -1
- package/element/thinking/src/index.vue.d.ts +26 -26
- package/element/thinking/src/types.d.ts +10 -0
- package/icons/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
- package/icons/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
- package/icons/end/index.cjs +1 -0
- package/icons/end/index.mjs +21 -26
- package/icons/end/src/index.vue.d.ts +3 -0
- package/icons/keyboard/index.cjs +1 -0
- package/icons/keyboard/index.mjs +21 -26
- package/icons/keyboard/src/index.vue.d.ts +3 -0
- package/icons/start/index.cjs +1 -0
- package/icons/start/index.mjs +21 -26
- package/icons/start/src/index.vue.d.ts +3 -0
- package/icons/voice/index.cjs +1 -0
- package/icons/voice/index.mjs +26 -44
- package/icons/voice/src/index.vue.d.ts +2 -3
- package/index.css +2 -558
- package/index.d.ts +1 -0
- package/package.json +78 -87
- package/shared/data/index.cjs +1 -0
- package/shared/data/index.mjs +16 -22
- package/shared/types/index.cjs +1 -0
- package/shared/types/index.d.ts +1 -0
- package/components/LinkOutlined.mjs +0 -1321
- package/components/_commonjsHelpers.mjs +0 -7
- package/components/_plugin-vue_export-helper.mjs +0 -9
- package/components/bubble-list/index.css +0 -70
- package/components/bubble-templates/index.css +0 -4
- package/components/chat-independent/index.css +0 -47
- package/components/drawer/index.css +0 -124
- package/components/index2.mjs +0 -78
- package/components/lottie-animation/index.css +0 -4
- package/components/monaco-editor/index.css +0 -4
- package/components/pixi-frame/index.css +0 -4
- package/components/recorder-button/index.css +0 -69
- package/components/sender/index.css +0 -22
- package/components/speech-button/index.css +0 -10
- package/components/tables-v1/index.css +0 -7
- package/components/tables-v1-checkbox/index.css +0 -8
- package/components/thinking/index.css +0 -125
- package/components/typing-markdown/index.css +0 -31
- package/components/vditor/index.css +0 -12
- package/components/xgplayer/index.css +0 -1
- package/icons/_plugin-vue_export-helper.mjs +0 -9
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
declare
|
|
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
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
3
|
-
declare const
|
|
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
|
|
2
|
-
import { ElButton, ElMessage } from
|
|
3
|
-
import { defineComponent, ref, onUnmounted, resolveComponent
|
|
4
|
-
import { _ as
|
|
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:
|
|
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:
|
|
36
|
+
default: !1
|
|
38
37
|
}
|
|
38
|
+
}, J = {
|
|
39
|
+
submitText: (e) => typeof e == "string",
|
|
40
|
+
submit: (e) => !0,
|
|
41
|
+
error: (e) => !0
|
|
39
42
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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:
|
|
48
|
+
body: r
|
|
52
49
|
});
|
|
53
|
-
if (!
|
|
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(
|
|
69
|
-
const
|
|
70
|
-
|
|
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
|
-
|
|
77
|
-
|
|
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
|
|
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 (
|
|
89
|
-
console.error("
|
|
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
|
-
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
else {
|
|
95
|
+
if (e.speechToText) {
|
|
96
|
+
e.speechToText(t).then((u) => {
|
|
97
|
+
s("submitText", u);
|
|
120
98
|
});
|
|
121
99
|
return;
|
|
122
100
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}).catch((
|
|
126
|
-
console.error("
|
|
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
|
-
|
|
134
|
-
|
|
135
|
-
document.
|
|
136
|
-
}
|
|
137
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
159
|
-
|
|
160
|
-
if (!isDragging.value)
|
|
121
|
+
function x(o) {
|
|
122
|
+
if (o.preventDefault(), !c.value)
|
|
161
123
|
return;
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
174
|
-
|
|
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
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
-
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
307
|
-
|
|
308
|
-
), [
|
|
309
|
-
[vShow, _ctx.isDragging]
|
|
186
|
+
])
|
|
187
|
+
], 512), [
|
|
188
|
+
[A, e.isDragging]
|
|
310
189
|
])
|
|
311
190
|
], 8, ["to"])),
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
disabled: _ctx.disabled,
|
|
191
|
+
Y(g, q(e.$attrs, {
|
|
192
|
+
disabled: e.disabled,
|
|
315
193
|
class: ["vk-recorder-button", {
|
|
316
|
-
"is-recording":
|
|
194
|
+
"is-recording": e.recording
|
|
317
195
|
}],
|
|
318
196
|
size: "large",
|
|
319
|
-
onTouchstart:
|
|
320
|
-
onTouchmove:
|
|
321
|
-
onTouchend:
|
|
322
|
-
onMousedown:
|
|
197
|
+
onTouchstart: e.onmousedown,
|
|
198
|
+
onTouchmove: e.onmousemove,
|
|
199
|
+
onTouchend: e.onmouseup,
|
|
200
|
+
onMousedown: e.onmousedown
|
|
323
201
|
}), {
|
|
324
|
-
default:
|
|
325
|
-
|
|
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
|
-
|
|
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
|
-
|
|
345
|
-
|
|
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 };
|