@sdata/web-vue 3.18.0 → 3.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sd.css +489 -0
- package/dist/sd.min.css +2 -2
- package/es/_components/icon-hover.vue.d.ts +1 -1
- package/es/_components/input-label/input-label.d.ts +13 -1
- package/es/_components/input-label/input-label.js +35 -5
- package/es/_components/input-label/style/index.css +6 -0
- package/es/_components/input-label/style/input-label.scss +8 -0
- package/es/_components/picker/input-range.vue.d.ts +24 -1
- package/es/_components/picker/input-range.vue_vue_type_script_setup_true_lang.js +42 -6
- package/es/_components/picker/input.vue.d.ts +24 -1
- package/es/_components/picker/input.vue_vue_type_script_setup_true_lang.js +31 -4
- package/es/_components/picker/style/index.scss +8 -0
- package/es/_components/select-view/select-view.d.ts +15 -3
- package/es/_components/select-view/select-view.js +10 -1
- package/es/_components/select-view/style/index.css +12 -0
- package/es/_components/virtual-list/virtual-list.vue.d.ts +6 -6
- package/es/_hooks/use-fit-width.d.ts +22 -0
- package/es/_hooks/use-fit-width.js +76 -0
- package/es/_hooks/use-form-item.d.ts +1 -1
- package/es/_hooks/use-size.d.ts +1 -1
- package/es/anchor/anchor.vue.d.ts +1 -1
- package/es/anchor/index.d.ts +3 -3
- package/es/auto-complete/auto-complete.d.ts +20 -2
- package/es/auto-complete/auto-complete.js +18 -0
- package/es/auto-complete/index.d.ts +36 -6
- package/es/basic-crud-table/basic-crud-table.vue.d.ts +2 -2
- package/es/basic-crud-table/basic-crud-table.vue_vue_type_script_setup_true_lang.js +6 -4
- package/es/basic-crud-table/index.d.ts +5 -5
- package/es/basic-crud-table/types.d.ts +2 -0
- package/es/button/button.vue.d.ts +2 -2
- package/es/button/index.d.ts +6 -6
- package/es/card/card.d.ts +25 -3
- package/es/card/card.js +11 -2
- package/es/card/index.d.ts +45 -6
- package/es/carousel/carousel-indicator.vue.d.ts +1 -1
- package/es/cascader/base-cascader-panel.d.ts +4 -1
- package/es/cascader/base-cascader-panel.js +2 -1
- package/es/cascader/cascader-option.d.ts +1 -1
- package/es/cascader/cascader-panel.vue.d.ts +1 -1
- package/es/cascader/cascader-search-panel.d.ts +4 -1
- package/es/cascader/cascader-search-panel.js +2 -1
- package/es/cascader/cascader.vue.d.ts +7 -5
- package/es/cascader/cascader.vue_vue_type_script_setup_true_lang.js +22 -2
- package/es/cascader/types.d.ts +4 -1
- package/es/checkbox/checkbox.d.ts +3 -3
- package/es/checkbox/index.d.ts +6 -6
- package/es/collapse/collapse-item.d.ts +3 -3
- package/es/collapse/index.d.ts +3 -3
- package/es/color-picker/color-picker.d.ts +2 -2
- package/es/color-picker/index.d.ts +6 -6
- package/es/components.d.ts +4 -0
- package/es/config-provider/config-provider.vue.d.ts +68 -1
- package/es/config-provider/config-provider.vue_vue_type_script_setup_true_lang.js +67 -1
- package/es/config-provider/context.d.ts +12 -0
- package/es/config-provider/index.d.ts +102 -3
- package/es/date-picker/index.d.ts +87 -23
- package/es/date-picker/interface.d.ts +2 -1
- package/es/date-picker/picker-panel.vue.d.ts +1 -1
- package/es/date-picker/picker.vue.d.ts +39 -17
- package/es/date-picker/picker.vue_vue_type_script_setup_true_lang.js +30 -1
- package/es/date-picker/pickers/date-picker.d.ts +18 -0
- package/es/date-picker/pickers/date-picker.js +16 -0
- package/es/date-picker/range-picker-panel.vue.d.ts +1 -1
- package/es/date-picker/range-picker.vue.d.ts +39 -17
- package/es/date-picker/range-picker.vue_vue_type_script_setup_true_lang.js +27 -1
- package/es/date-picker/style/index.css +6 -0
- package/es/descriptions/descriptions.d.ts +3 -3
- package/es/descriptions/index.d.ts +9 -9
- package/es/divider/divider.d.ts +1 -1
- package/es/divider/index.d.ts +3 -3
- package/es/drawer/drawer.vue.d.ts +4 -4
- package/es/drawer/drawer.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/drawer/index.d.ts +11 -11
- package/es/dropdown/dropdown-button.vue.d.ts +2 -2
- package/es/dropdown/dropdown-option.vue.d.ts +1 -1
- package/es/dropdown/dropdown-submenu.vue.d.ts +2 -2
- package/es/dropdown/dropdown.vue.d.ts +1 -1
- package/es/dropdown/index.d.ts +21 -21
- package/es/ellipsis/ellipsis.vue.d.ts +1 -1
- package/es/ellipsis/index.d.ts +6 -6
- package/es/ellipsis/performant-ellipsis.vue.d.ts +1 -1
- package/es/form/form-item.vue.d.ts +1 -1
- package/es/form/form.vue.d.ts +1 -1
- package/es/form/index.d.ts +9 -9
- package/es/grid/grid-row.vue.d.ts +3 -3
- package/es/grid/index.d.ts +9 -9
- package/es/icon/icon-arrow-up/icon-arrow-up.js +5 -0
- package/es/icon/icon-arrow-up/icon-arrow-up.vue_vue_type_script_setup_true_lang.js +52 -0
- package/es/icon/icon-arrow-up/index.js +9 -0
- package/es/icon/icon-mute/icon-mute.js +5 -0
- package/es/icon/icon-mute/icon-mute.vue_vue_type_script_setup_true_lang.js +52 -0
- package/es/icon/icon-mute/index.js +9 -0
- package/es/icon/icon-voice/icon-voice.js +5 -0
- package/es/icon/icon-voice/icon-voice.vue_vue_type_script_setup_true_lang.js +52 -0
- package/es/icon/icon-voice/index.js +9 -0
- package/es/image/preview-action.d.ts +6 -6
- package/es/image/preview-group.vue.d.ts +1 -1
- package/es/index.css +489 -0
- package/es/index.d.ts +6 -1
- package/es/index.js +5 -1
- package/es/index.scss +2 -0
- package/es/input/index.d.ts +99 -6
- package/es/input/input-password.vue.d.ts +18 -0
- package/es/input/input-password.vue_vue_type_script_setup_true_lang.js +24 -2
- package/es/input/input-search.d.ts +18 -0
- package/es/input/input-search.js +20 -2
- package/es/input/input.d.ts +29 -2
- package/es/input/input.js +45 -3
- package/es/input/style/index.css +16 -0
- package/es/input/style/index.scss +21 -0
- package/es/input-number/index.d.ts +36 -6
- package/es/input-number/input-number.d.ts +20 -2
- package/es/input-number/input-number.js +19 -0
- package/es/input-tag/index.d.ts +36 -6
- package/es/input-tag/input-tag.d.ts +20 -2
- package/es/input-tag/input-tag.js +35 -4
- package/es/input-tag/style/index.css +6 -0
- package/es/input-tag/style/input-tag.scss +8 -0
- package/es/kv-list/index.d.ts +72 -32
- package/es/link/index.d.ts +6 -6
- package/es/link/link.vue.d.ts +2 -2
- package/es/list/index.d.ts +9 -0
- package/es/list/list.d.ts +7 -0
- package/es/list/list.js +8 -2
- package/es/locale/interface.d.ts +22 -0
- package/es/locale/lang/ar-eg.js +21 -1
- package/es/locale/lang/de-de.js +21 -1
- package/es/locale/lang/en-us.js +21 -1
- package/es/locale/lang/es-es.js +21 -1
- package/es/locale/lang/fr-fr.js +21 -1
- package/es/locale/lang/id-id.js +21 -1
- package/es/locale/lang/it-it.js +21 -1
- package/es/locale/lang/ja-jp.js +21 -1
- package/es/locale/lang/km-kh.js +21 -1
- package/es/locale/lang/ko-kr.js +21 -1
- package/es/locale/lang/ms-my.js +21 -1
- package/es/locale/lang/nl-nl.js +21 -1
- package/es/locale/lang/pt-pt.js +21 -1
- package/es/locale/lang/ru-ru.js +21 -1
- package/es/locale/lang/th-th.js +21 -1
- package/es/locale/lang/vi-vn.js +21 -1
- package/es/locale/lang/zh-cn.js +21 -1
- package/es/locale/lang/zh-tw.js +21 -1
- package/es/mention/index.d.ts +39 -9
- package/es/mention/mention.d.ts +21 -3
- package/es/mention/mention.js +24 -1
- package/es/mention/style/index.css +6 -0
- package/es/mention/style/index.scss +8 -0
- package/es/menu/item.d.ts +1 -1
- package/es/message/message-list.d.ts +1 -1
- package/es/modal/index.d.ts +9 -9
- package/es/modal/modal.vue.d.ts +3 -3
- package/es/modal/modal.vue_vue_type_script_setup_true_lang.js +1 -1
- package/es/popconfirm/index.d.ts +3 -3
- package/es/popconfirm/popconfirm.vue.d.ts +1 -1
- package/es/popover/index.d.ts +6 -6
- package/es/popover/popover.vue.d.ts +2 -2
- package/es/progress/circle.vue.d.ts +1 -1
- package/es/progress/line.vue.d.ts +1 -1
- package/es/qr-code/index.d.ts +27 -21
- package/es/qr-code/qr-code.vue.d.ts +8 -6
- package/es/qr-code/qr-code.vue_vue_type_script_setup_true_lang.js +5 -2
- package/es/radio/index.d.ts +6 -6
- package/es/radio/radio.d.ts +3 -3
- package/es/rate/index.d.ts +3 -3
- package/es/rate/rate.d.ts +1 -1
- package/es/resize-box/index.d.ts +5 -5
- package/es/resize-box/resize-box.vue.d.ts +3 -3
- package/es/rich-text-editor/built-in-components.d.ts +5 -0
- package/es/rich-text-editor/built-in-components.js +6 -0
- package/es/rich-text-editor/index.d.ts +195 -0
- package/es/rich-text-editor/index.js +12 -0
- package/es/rich-text-editor/nodes/inline-component-node.d.ts +30 -0
- package/es/rich-text-editor/nodes/inline-component-node.js +86 -0
- package/es/rich-text-editor/rich-text-editor.js +5 -0
- package/es/rich-text-editor/rich-text-editor.vue.d.ts +76 -0
- package/es/rich-text-editor/rich-text-editor.vue_vue_type_script_setup_true_lang.js +630 -0
- package/es/rich-text-editor/rich-text-node-renderer.js +5 -0
- package/es/rich-text-editor/rich-text-node-renderer.vue.d.ts +28 -0
- package/es/rich-text-editor/rich-text-node-renderer.vue_vue_type_script_setup_true_lang.js +133 -0
- package/es/rich-text-editor/style/css.js +2 -0
- package/es/rich-text-editor/style/index.css +164 -0
- package/es/rich-text-editor/style/index.d.ts +2 -0
- package/es/rich-text-editor/style/index.js +2 -0
- package/es/rich-text-editor/style/index.scss +193 -0
- package/es/rich-text-editor/style/token.scss +36 -0
- package/es/rich-text-editor/types.d.ts +148 -0
- package/es/sd-vue.js +6 -0
- package/es/select/index.d.ts +117 -54
- package/es/select/interface.d.ts +2 -1
- package/es/select/select-dropdown.vue.d.ts +3 -0
- package/es/select/select-dropdown.vue_vue_type_script_setup_true_lang.js +2 -4
- package/es/select/select.d.ts +62 -25
- package/es/select/select.js +28 -1
- package/es/sender/context.d.ts +8 -0
- package/es/sender/context.js +4 -0
- package/es/sender/index.d.ts +119 -0
- package/es/sender/index.js +20 -0
- package/es/sender/sender-header.js +5 -0
- package/es/sender/sender-header.vue.d.ts +28 -0
- package/es/sender/sender-header.vue_vue_type_script_setup_true_lang.js +127 -0
- package/es/sender/sender-switch.js +5 -0
- package/es/sender/sender-switch.vue.d.ts +32 -0
- package/es/sender/sender-switch.vue_vue_type_script_setup_true_lang.js +95 -0
- package/es/sender/sender.js +5 -0
- package/es/sender/sender.vue_vue_type_script_setup_true_lang.js +895 -0
- package/es/sender/style/css.js +3 -0
- package/es/sender/style/index.css +301 -0
- package/es/sender/style/index.d.ts +3 -0
- package/es/sender/style/index.js +3 -0
- package/es/sender/style/index.scss +359 -0
- package/es/sender/style/token.scss +43 -0
- package/es/sender/types.d.ts +228 -0
- package/es/sender/use-speech.d.ts +19 -0
- package/es/sender/use-speech.js +338 -0
- package/es/slider/index.d.ts +3 -3
- package/es/slider/slider-input.vue.d.ts +1 -1
- package/es/slider/slider.vue.d.ts +1 -1
- package/es/space/index.d.ts +9 -9
- package/es/space/space.d.ts +2 -2
- package/es/spin/index.d.ts +18 -3
- package/es/spin/spin.d.ts +10 -1
- package/es/spin/spin.js +72 -10
- package/es/statistic/index.d.ts +3 -3
- package/es/statistic/statistic.vue.d.ts +1 -1
- package/es/steps/index.d.ts +5 -5
- package/es/steps/step.vue.d.ts +2 -2
- package/es/steps/steps.vue.d.ts +1 -1
- package/es/table/index.d.ts +68 -23
- package/es/table/interface.d.ts +3 -0
- package/es/table/table-column.d.ts +1 -1
- package/es/table/table-operation-td.d.ts +12 -12
- package/es/table/table-td.d.ts +2 -2
- package/es/table/table.d.ts +27 -8
- package/es/table/table.js +7 -2
- package/es/tabs/index.d.ts +12 -12
- package/es/tabs/tabs-nav.d.ts +1 -1
- package/es/tabs/tabs.d.ts +4 -4
- package/es/tag/index.d.ts +6 -6
- package/es/tag/tag.vue.d.ts +2 -2
- package/es/textarea/index.d.ts +38 -8
- package/es/textarea/style/index.css +6 -0
- package/es/textarea/style/index.scss +8 -0
- package/es/textarea/textarea.vue.d.ts +21 -3
- package/es/textarea/textarea.vue_vue_type_script_setup_true_lang.js +36 -3
- package/es/time-picker/index.d.ts +36 -6
- package/es/time-picker/interface.d.ts +2 -1
- package/es/time-picker/range-panel.js +58 -0
- package/es/time-picker/time-picker.vue.d.ts +20 -2
- package/es/time-picker/time-picker.vue_vue_type_script_setup_true_lang.js +30 -1
- package/es/timeline/index.d.ts +45 -6
- package/es/timeline/timeline.d.ts +25 -3
- package/es/timeline/timeline.js +11 -2
- package/es/toolbar/toolbar.vue_vue_type_script_setup_true_lang.js +9 -5
- package/es/toolbar/types.d.ts +2 -0
- package/es/tooltip/index.d.ts +6 -6
- package/es/tooltip/tooltip.vue.d.ts +2 -2
- package/es/tour/index.d.ts +3 -3
- package/es/tour/tour.vue.d.ts +1 -1
- package/es/transfer/index.d.ts +3 -3
- package/es/transfer/transfer.vue.d.ts +1 -1
- package/es/tree/tree.vue.d.ts +4 -4
- package/es/tree-select/interface.d.ts +2 -1
- package/es/tree-select/tree-select.vue.d.ts +32 -7
- package/es/tree-select/tree-select.vue_vue_type_script_setup_true_lang.js +27 -1
- package/es/trigger/index.d.ts +12 -12
- package/es/trigger/trigger.d.ts +4 -4
- package/es/typography/base.d.ts +4 -4
- package/es/typography/edit-content.vue.d.ts +2 -2
- package/es/upload/index.d.ts +6 -6
- package/es/upload/upload-button.d.ts +1 -1
- package/es/upload/upload.d.ts +2 -2
- package/es/verification-code/index.d.ts +3 -3
- package/es/verification-code/verification-code.d.ts +1 -1
- package/es/watermark/index.d.ts +3 -3
- package/es/watermark/watermark.d.ts +1 -1
- package/json/vetur-attributes.json +295 -2
- package/json/vetur-tags.json +103 -3
- package/json/web-types.json +746 -53
- package/package.json +10 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import type { CSSProperties, Component, VNodeChild } from 'vue';
|
|
2
|
+
import type { TooltipProps } from '../tooltip';
|
|
3
|
+
export type SenderSubmitType = 'enter' | 'shiftEnter';
|
|
4
|
+
export type SenderInsertPosition = 'start' | 'end' | 'cursor';
|
|
5
|
+
export type SenderSuffixPlacement = 'content' | 'footer';
|
|
6
|
+
export type SenderSemanticType = 'root' | 'prefix' | 'input' | 'suffix' | 'footer' | 'switch' | 'content';
|
|
7
|
+
export interface SenderComponents {
|
|
8
|
+
input?: Component;
|
|
9
|
+
}
|
|
10
|
+
export interface SenderSpeechConfig {
|
|
11
|
+
recording?: boolean;
|
|
12
|
+
onRecordingChange?: (recording: boolean) => void;
|
|
13
|
+
audioConstraints?: MediaTrackConstraints;
|
|
14
|
+
bufferSize?: number;
|
|
15
|
+
workletUrl?: string;
|
|
16
|
+
processorName?: string;
|
|
17
|
+
processorOptions?: Record<string, unknown>;
|
|
18
|
+
url?: string;
|
|
19
|
+
protocols?: string | string[];
|
|
20
|
+
sendMetadata?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type SenderControlledSpeechConfig = SenderSpeechConfig;
|
|
23
|
+
export type SenderAllowSpeech = boolean | SenderSpeechConfig;
|
|
24
|
+
export interface SenderSpeechStartEvent {
|
|
25
|
+
source: 'capture' | 'controlled';
|
|
26
|
+
startedAt: number;
|
|
27
|
+
stream?: MediaStream;
|
|
28
|
+
audioContext?: AudioContext;
|
|
29
|
+
sampleRate?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface SenderSpeechDataEvent {
|
|
32
|
+
buffer: ArrayBuffer;
|
|
33
|
+
sampleRate: number;
|
|
34
|
+
sequence: number;
|
|
35
|
+
timestamp: number;
|
|
36
|
+
}
|
|
37
|
+
export type SenderSpeechEndReason = 'manual' | 'controlled' | 'error' | 'unmount';
|
|
38
|
+
export interface SenderSpeechEndEvent {
|
|
39
|
+
source: 'capture' | 'controlled';
|
|
40
|
+
reason: SenderSpeechEndReason;
|
|
41
|
+
startedAt: number;
|
|
42
|
+
endedAt: number;
|
|
43
|
+
duration: number;
|
|
44
|
+
chunks: number;
|
|
45
|
+
}
|
|
46
|
+
export type SenderSpeechErrorPhase = 'permission' | 'audioContext' | 'audioWorklet' | 'transport';
|
|
47
|
+
export interface SenderSpeechErrorEvent {
|
|
48
|
+
error: Error;
|
|
49
|
+
phase: SenderSpeechErrorPhase;
|
|
50
|
+
}
|
|
51
|
+
export interface SenderSpeechTransportOpenEvent {
|
|
52
|
+
event: Event;
|
|
53
|
+
socket: WebSocket;
|
|
54
|
+
}
|
|
55
|
+
export interface SenderSpeechTransportMessageEvent {
|
|
56
|
+
event: MessageEvent;
|
|
57
|
+
socket: WebSocket;
|
|
58
|
+
}
|
|
59
|
+
export interface SenderSpeechTransportCloseEvent {
|
|
60
|
+
event: CloseEvent;
|
|
61
|
+
socket: WebSocket;
|
|
62
|
+
}
|
|
63
|
+
export interface SenderSkillClosableConfig {
|
|
64
|
+
closeIcon?: VNodeChild;
|
|
65
|
+
onClose?: (event: MouseEvent) => void;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface SenderSkill {
|
|
69
|
+
title?: VNodeChild;
|
|
70
|
+
value: string;
|
|
71
|
+
tooltip?: string | TooltipProps;
|
|
72
|
+
closable?: boolean | SenderSkillClosableConfig;
|
|
73
|
+
}
|
|
74
|
+
export interface SenderSlotConfigBase {
|
|
75
|
+
type: 'text' | 'input' | 'select' | 'tag' | 'custom' | 'content';
|
|
76
|
+
formatResult?: (value: unknown) => string;
|
|
77
|
+
}
|
|
78
|
+
export interface SenderTextSlotConfig extends SenderSlotConfigBase {
|
|
79
|
+
type: 'text';
|
|
80
|
+
value?: string;
|
|
81
|
+
editable?: boolean;
|
|
82
|
+
placeholder?: string;
|
|
83
|
+
key?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface SenderInputSlotConfig extends SenderSlotConfigBase {
|
|
86
|
+
type: 'input';
|
|
87
|
+
key: string;
|
|
88
|
+
props?: {
|
|
89
|
+
defaultValue?: string | number;
|
|
90
|
+
placeholder?: string;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export interface SenderSelectSlotConfig extends SenderSlotConfigBase {
|
|
94
|
+
type: 'select';
|
|
95
|
+
key: string;
|
|
96
|
+
props?: {
|
|
97
|
+
defaultValue?: string;
|
|
98
|
+
options: string[];
|
|
99
|
+
placeholder?: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export interface SenderTagSlotConfig extends SenderSlotConfigBase {
|
|
103
|
+
type: 'tag';
|
|
104
|
+
key: string;
|
|
105
|
+
props?: {
|
|
106
|
+
label: string | number;
|
|
107
|
+
value?: string;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export interface SenderContentSlotConfig extends SenderSlotConfigBase {
|
|
111
|
+
type: 'content';
|
|
112
|
+
key: string;
|
|
113
|
+
props?: {
|
|
114
|
+
defaultValue?: unknown;
|
|
115
|
+
placeholder?: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
export interface SenderCustomSlotState {
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
readonly?: boolean;
|
|
121
|
+
}
|
|
122
|
+
export type SenderCustomSlotRender = (value: unknown, onChange: (value: unknown) => void, state: SenderCustomSlotState, item: SenderCustomSlotConfig) => VNodeChild;
|
|
123
|
+
export interface SenderCustomSlotConfig extends SenderSlotConfigBase {
|
|
124
|
+
type: 'custom';
|
|
125
|
+
key: string;
|
|
126
|
+
props?: {
|
|
127
|
+
defaultValue?: unknown;
|
|
128
|
+
[key: string]: unknown;
|
|
129
|
+
};
|
|
130
|
+
customRender?: SenderCustomSlotRender;
|
|
131
|
+
}
|
|
132
|
+
export type SenderSlotConfig = SenderTextSlotConfig | SenderInputSlotConfig | SenderSelectSlotConfig | SenderTagSlotConfig | SenderContentSlotConfig | SenderCustomSlotConfig;
|
|
133
|
+
export type SenderResolvedSlotConfig = SenderSlotConfig & {
|
|
134
|
+
value?: unknown;
|
|
135
|
+
};
|
|
136
|
+
export interface SenderValue {
|
|
137
|
+
value: string;
|
|
138
|
+
slotConfig: SenderResolvedSlotConfig[];
|
|
139
|
+
skill?: SenderSkill;
|
|
140
|
+
}
|
|
141
|
+
export interface SenderFocusOptions {
|
|
142
|
+
preventScroll?: boolean;
|
|
143
|
+
cursor?: 'start' | 'end' | 'all' | 'slot';
|
|
144
|
+
key?: string;
|
|
145
|
+
}
|
|
146
|
+
export interface SenderRef {
|
|
147
|
+
readonly inputElement: HTMLTextAreaElement | HTMLDivElement | null;
|
|
148
|
+
readonly nativeElement: HTMLDivElement | null;
|
|
149
|
+
focus: (options?: SenderFocusOptions) => void;
|
|
150
|
+
blur: () => void;
|
|
151
|
+
insert: (value: string | SenderSlotConfig[], position?: SenderInsertPosition, replaceCharacters?: string, preventScroll?: boolean) => void;
|
|
152
|
+
clear: () => void;
|
|
153
|
+
getValue: () => SenderValue;
|
|
154
|
+
}
|
|
155
|
+
export interface SenderActionContext {
|
|
156
|
+
send: () => void;
|
|
157
|
+
clear: () => void;
|
|
158
|
+
cancel: () => void;
|
|
159
|
+
speech: () => void;
|
|
160
|
+
submitDisabled: boolean;
|
|
161
|
+
clearDisabled: boolean;
|
|
162
|
+
cancelDisabled: boolean;
|
|
163
|
+
speechDisabled: boolean;
|
|
164
|
+
recording: boolean;
|
|
165
|
+
loading: boolean;
|
|
166
|
+
}
|
|
167
|
+
export interface SenderProps {
|
|
168
|
+
modelValue?: string;
|
|
169
|
+
defaultValue?: string;
|
|
170
|
+
loading?: boolean;
|
|
171
|
+
readonly?: boolean | string;
|
|
172
|
+
submitType?: SenderSubmitType;
|
|
173
|
+
disabled?: boolean;
|
|
174
|
+
slotConfig?: readonly SenderSlotConfig[];
|
|
175
|
+
allowSpeech?: SenderAllowSpeech;
|
|
176
|
+
autoSize?: boolean | {
|
|
177
|
+
minRows?: number;
|
|
178
|
+
maxRows?: number;
|
|
179
|
+
};
|
|
180
|
+
skill?: SenderSkill;
|
|
181
|
+
placeholder?: string;
|
|
182
|
+
showActions?: boolean;
|
|
183
|
+
suffixPlacement?: SenderSuffixPlacement;
|
|
184
|
+
components?: SenderComponents;
|
|
185
|
+
classNames?: Partial<Record<SenderSemanticType, string>>;
|
|
186
|
+
styles?: Partial<Record<SenderSemanticType, CSSProperties>>;
|
|
187
|
+
onKeydown?: (event: KeyboardEvent) => void | false;
|
|
188
|
+
onKeyup?: (event: KeyboardEvent) => void;
|
|
189
|
+
}
|
|
190
|
+
export interface SenderEmits {
|
|
191
|
+
'update:modelValue': [value: string];
|
|
192
|
+
'change': [
|
|
193
|
+
value: string,
|
|
194
|
+
event: Event | undefined,
|
|
195
|
+
slotConfig: SenderResolvedSlotConfig[],
|
|
196
|
+
skill: SenderSkill | undefined
|
|
197
|
+
];
|
|
198
|
+
'submit': [value: string, slotConfig: SenderResolvedSlotConfig[], skill: SenderSkill | undefined];
|
|
199
|
+
'cancel': [];
|
|
200
|
+
'paste': [event: ClipboardEvent];
|
|
201
|
+
'pasteFile': [files: FileList];
|
|
202
|
+
'focus': [event: FocusEvent];
|
|
203
|
+
'blur': [event: FocusEvent];
|
|
204
|
+
'speechStart': [event: SenderSpeechStartEvent];
|
|
205
|
+
'speechData': [event: SenderSpeechDataEvent];
|
|
206
|
+
'speechEnd': [event: SenderSpeechEndEvent];
|
|
207
|
+
'speechError': [event: SenderSpeechErrorEvent];
|
|
208
|
+
'speechTransportOpen': [event: SenderSpeechTransportOpenEvent];
|
|
209
|
+
'speechTransportMessage': [event: SenderSpeechTransportMessageEvent];
|
|
210
|
+
'speechTransportClose': [event: SenderSpeechTransportCloseEvent];
|
|
211
|
+
}
|
|
212
|
+
export type SenderHeaderSemanticType = 'header' | 'content';
|
|
213
|
+
export interface SenderHeaderProps {
|
|
214
|
+
open?: boolean;
|
|
215
|
+
forceRender?: boolean;
|
|
216
|
+
title?: VNodeChild;
|
|
217
|
+
closable?: boolean;
|
|
218
|
+
classNames?: Partial<Record<SenderHeaderSemanticType, string>>;
|
|
219
|
+
styles?: Partial<Record<SenderHeaderSemanticType, CSSProperties>>;
|
|
220
|
+
}
|
|
221
|
+
export interface SenderSwitchProps {
|
|
222
|
+
modelValue?: boolean;
|
|
223
|
+
defaultValue?: boolean;
|
|
224
|
+
disabled?: boolean;
|
|
225
|
+
loading?: boolean;
|
|
226
|
+
classNames?: Partial<Record<'root' | 'content' | 'icon' | 'title', string>>;
|
|
227
|
+
styles?: Partial<Record<'root' | 'content' | 'icon' | 'title', CSSProperties>>;
|
|
228
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import type { SenderAllowSpeech, SenderSpeechDataEvent, SenderSpeechEndEvent, SenderSpeechErrorEvent, SenderSpeechStartEvent, SenderSpeechTransportCloseEvent, SenderSpeechTransportMessageEvent, SenderSpeechTransportOpenEvent } from './types';
|
|
3
|
+
interface UseSpeechOptions {
|
|
4
|
+
onStart: (event: SenderSpeechStartEvent) => void;
|
|
5
|
+
onData: (event: SenderSpeechDataEvent) => void;
|
|
6
|
+
onEnd: (event: SenderSpeechEndEvent) => void;
|
|
7
|
+
onError: (event: SenderSpeechErrorEvent) => void;
|
|
8
|
+
onTransportOpen: (event: SenderSpeechTransportOpenEvent) => void;
|
|
9
|
+
onTransportMessage: (event: SenderSpeechTransportMessageEvent) => void;
|
|
10
|
+
onTransportClose: (event: SenderSpeechTransportCloseEvent) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function useSpeech(allowSpeech: MaybeRefOrGetter<SenderAllowSpeech | undefined>, options: UseSpeechOptions): {
|
|
13
|
+
available: import("vue").ComputedRef<boolean>;
|
|
14
|
+
recording: import("vue").ComputedRef<boolean>;
|
|
15
|
+
requesting: import("vue").ShallowRef<boolean, boolean>;
|
|
16
|
+
statusText: import("vue").ComputedRef<string>;
|
|
17
|
+
trigger: (breakRecording?: boolean) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import _objectSpread2 from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/objectSpread2.js";
|
|
2
|
+
import { useI18n } from "../locale/index.js";
|
|
3
|
+
import _asyncToGenerator from "../_virtual/_@oxc-project_runtime@0.139.0/helpers/esm/asyncToGenerator.js";
|
|
4
|
+
import { computed, onBeforeUnmount, onMounted, shallowRef, toValue, watch } from "vue";
|
|
5
|
+
//#region components/sender/use-speech.ts
|
|
6
|
+
var DEFAULT_PROCESSOR_NAME = "sd-sender-audio-processor";
|
|
7
|
+
var DEFAULT_BUFFER_SIZE = 4096;
|
|
8
|
+
var resolveBufferSize = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(128, Math.floor(value)) : DEFAULT_BUFFER_SIZE;
|
|
9
|
+
var WORKLET_SOURCE = `
|
|
10
|
+
class SdSenderAudioProcessor extends AudioWorkletProcessor {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
super();
|
|
13
|
+
this.bufferSize = Math.max(128, options.processorOptions?.bufferSize || ${DEFAULT_BUFFER_SIZE});
|
|
14
|
+
this.buffer = new Float32Array(this.bufferSize);
|
|
15
|
+
this.offset = 0;
|
|
16
|
+
this.port.onmessage = (event) => {
|
|
17
|
+
if (event.data?.type !== 'flush') return;
|
|
18
|
+
if (this.offset > 0) {
|
|
19
|
+
const chunk = this.buffer.slice(0, this.offset);
|
|
20
|
+
this.port.postMessage(chunk.buffer, [chunk.buffer]);
|
|
21
|
+
this.offset = 0;
|
|
22
|
+
}
|
|
23
|
+
this.port.postMessage({ type: 'flushed' });
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
process(inputs) {
|
|
28
|
+
const channels = inputs[0];
|
|
29
|
+
if (!channels?.length) return true;
|
|
30
|
+
const frames = channels[0].length;
|
|
31
|
+
for (let frame = 0; frame < frames; frame += 1) {
|
|
32
|
+
let sample = 0;
|
|
33
|
+
for (let channel = 0; channel < channels.length; channel += 1) {
|
|
34
|
+
sample += channels[channel][frame] || 0;
|
|
35
|
+
}
|
|
36
|
+
this.buffer[this.offset] = sample / channels.length;
|
|
37
|
+
this.offset += 1;
|
|
38
|
+
if (this.offset === this.bufferSize) {
|
|
39
|
+
const chunk = this.buffer;
|
|
40
|
+
this.port.postMessage(chunk.buffer, [chunk.buffer]);
|
|
41
|
+
this.buffer = new Float32Array(this.bufferSize);
|
|
42
|
+
this.offset = 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
registerProcessor('${DEFAULT_PROCESSOR_NAME}', SdSenderAudioProcessor);
|
|
49
|
+
`;
|
|
50
|
+
var isPermissionDeniedError = (error) => error instanceof DOMException ? error.name === "NotAllowedError" || error.name === "SecurityError" : error instanceof Error && (error.name === "NotAllowedError" || error.name === "SecurityError");
|
|
51
|
+
function useSpeech(allowSpeech, options) {
|
|
52
|
+
const { t } = useI18n();
|
|
53
|
+
const config = computed(() => toValue(allowSpeech));
|
|
54
|
+
const controlled = computed(() => typeof config.value === "object" && typeof config.value.recording === "boolean" && typeof config.value.onRecordingChange === "function");
|
|
55
|
+
const supported = shallowRef(false);
|
|
56
|
+
const internalRecording = shallowRef(false);
|
|
57
|
+
const requesting = shallowRef(false);
|
|
58
|
+
const captureError = shallowRef();
|
|
59
|
+
const stream = shallowRef();
|
|
60
|
+
const audioContext = shallowRef();
|
|
61
|
+
const sourceNode = shallowRef();
|
|
62
|
+
const workletNode = shallowRef();
|
|
63
|
+
const socket = shallowRef();
|
|
64
|
+
const startedAt = shallowRef(0);
|
|
65
|
+
const chunks = shallowRef(0);
|
|
66
|
+
const sequence = shallowRef(0);
|
|
67
|
+
let generatedWorkletUrl;
|
|
68
|
+
let resolveWorkletFlush;
|
|
69
|
+
let disposed = false;
|
|
70
|
+
const recording = computed(() => controlled.value && typeof config.value === "object" ? Boolean(config.value.recording) : internalRecording.value);
|
|
71
|
+
const available = computed(() => Boolean(config.value) && (controlled.value || supported.value) && !(captureError.value && isPermissionDeniedError(captureError.value.error)));
|
|
72
|
+
const statusText = computed(() => {
|
|
73
|
+
var _captureError$value;
|
|
74
|
+
if (requesting.value) return t("sender.speech.requestingPermission");
|
|
75
|
+
if (captureError.value && isPermissionDeniedError(captureError.value.error)) return t("sender.speech.permissionDenied");
|
|
76
|
+
if (!controlled.value && !supported.value) return t("sender.speech.unsupported");
|
|
77
|
+
if (recording.value) return t("sender.speech.stop");
|
|
78
|
+
if (((_captureError$value = captureError.value) === null || _captureError$value === void 0 ? void 0 : _captureError$value.error.name) === "NotFoundError") return t("sender.speech.noMicrophone");
|
|
79
|
+
if (captureError.value) return t("sender.speech.microphoneUnavailable");
|
|
80
|
+
return t("sender.speech.start");
|
|
81
|
+
});
|
|
82
|
+
const resolveAudioContext = () => {
|
|
83
|
+
var _window$AudioContext;
|
|
84
|
+
const AudioContextConstructor = (_window$AudioContext = window.AudioContext) !== null && _window$AudioContext !== void 0 ? _window$AudioContext : window.webkitAudioContext;
|
|
85
|
+
if (!AudioContextConstructor) throw new Error("AudioContext is not supported");
|
|
86
|
+
return new AudioContextConstructor();
|
|
87
|
+
};
|
|
88
|
+
const resolveWorkletUrl = () => {
|
|
89
|
+
var _generatedWorkletUrl;
|
|
90
|
+
if (typeof config.value === "object" && config.value.workletUrl) return config.value.workletUrl;
|
|
91
|
+
(_generatedWorkletUrl = generatedWorkletUrl) !== null && _generatedWorkletUrl !== void 0 || (generatedWorkletUrl = URL.createObjectURL(new Blob([WORKLET_SOURCE], { type: "text/javascript" })));
|
|
92
|
+
return generatedWorkletUrl;
|
|
93
|
+
};
|
|
94
|
+
const connectTransport = (url, protocols) => new Promise((resolve, reject) => {
|
|
95
|
+
const nextSocket = protocols ? new WebSocket(url, protocols) : new WebSocket(url);
|
|
96
|
+
let opened = false;
|
|
97
|
+
socket.value = nextSocket;
|
|
98
|
+
nextSocket.binaryType = "arraybuffer";
|
|
99
|
+
nextSocket.onopen = (event) => {
|
|
100
|
+
opened = true;
|
|
101
|
+
options.onTransportOpen({
|
|
102
|
+
event,
|
|
103
|
+
socket: nextSocket
|
|
104
|
+
});
|
|
105
|
+
resolve(nextSocket);
|
|
106
|
+
};
|
|
107
|
+
nextSocket.onmessage = (event) => options.onTransportMessage({
|
|
108
|
+
event,
|
|
109
|
+
socket: nextSocket
|
|
110
|
+
});
|
|
111
|
+
nextSocket.onclose = (event) => options.onTransportClose({
|
|
112
|
+
event,
|
|
113
|
+
socket: nextSocket
|
|
114
|
+
});
|
|
115
|
+
nextSocket.onerror = () => {
|
|
116
|
+
const errorEvent = {
|
|
117
|
+
error: /* @__PURE__ */ new Error(`Unable to connect to speech URL: ${url}`),
|
|
118
|
+
phase: "transport"
|
|
119
|
+
};
|
|
120
|
+
if (opened) options.onError(errorEvent);
|
|
121
|
+
else reject(errorEvent.error);
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
const flushWorklet = () => new Promise((resolve) => {
|
|
125
|
+
var _workletNode$value;
|
|
126
|
+
const port = (_workletNode$value = workletNode.value) === null || _workletNode$value === void 0 ? void 0 : _workletNode$value.port;
|
|
127
|
+
if (!port) {
|
|
128
|
+
resolve();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const timeout = window.setTimeout(resolve, 100);
|
|
132
|
+
resolveWorkletFlush = () => {
|
|
133
|
+
window.clearTimeout(timeout);
|
|
134
|
+
resolveWorkletFlush = void 0;
|
|
135
|
+
resolve();
|
|
136
|
+
};
|
|
137
|
+
port.postMessage({ type: "flush" });
|
|
138
|
+
});
|
|
139
|
+
const releaseResources = function() {
|
|
140
|
+
var _ref = _asyncToGenerator(function* () {
|
|
141
|
+
var _workletNode$value2, _sourceNode$value, _stream$value, _audioContext$value, _audioContext$value2;
|
|
142
|
+
(_workletNode$value2 = workletNode.value) === null || _workletNode$value2 === void 0 || _workletNode$value2.disconnect();
|
|
143
|
+
(_sourceNode$value = sourceNode.value) === null || _sourceNode$value === void 0 || _sourceNode$value.disconnect();
|
|
144
|
+
(_stream$value = stream.value) === null || _stream$value === void 0 || _stream$value.getTracks().forEach((track) => track.stop());
|
|
145
|
+
if (((_audioContext$value = audioContext.value) === null || _audioContext$value === void 0 ? void 0 : _audioContext$value.state) !== "closed") yield (_audioContext$value2 = audioContext.value) === null || _audioContext$value2 === void 0 ? void 0 : _audioContext$value2.close();
|
|
146
|
+
if (socket.value && (socket.value.readyState === WebSocket.OPEN || socket.value.readyState === WebSocket.CONNECTING)) socket.value.close(1e3, "speech-ended");
|
|
147
|
+
workletNode.value = void 0;
|
|
148
|
+
sourceNode.value = void 0;
|
|
149
|
+
stream.value = void 0;
|
|
150
|
+
audioContext.value = void 0;
|
|
151
|
+
socket.value = void 0;
|
|
152
|
+
});
|
|
153
|
+
return function releaseResources() {
|
|
154
|
+
return _ref.apply(this, arguments);
|
|
155
|
+
};
|
|
156
|
+
}();
|
|
157
|
+
const stopCapture = function() {
|
|
158
|
+
var _ref2 = _asyncToGenerator(function* (reason = "manual") {
|
|
159
|
+
var _socket$value, _config$value$onRecor, _config$value;
|
|
160
|
+
if (!internalRecording.value) return;
|
|
161
|
+
yield flushWorklet();
|
|
162
|
+
const endedAt = performance.now();
|
|
163
|
+
internalRecording.value = false;
|
|
164
|
+
if (((_socket$value = socket.value) === null || _socket$value === void 0 ? void 0 : _socket$value.readyState) === WebSocket.OPEN && typeof config.value === "object" && config.value.sendMetadata !== false) socket.value.send(JSON.stringify({
|
|
165
|
+
type: "end",
|
|
166
|
+
reason
|
|
167
|
+
}));
|
|
168
|
+
yield releaseResources();
|
|
169
|
+
if (typeof config.value === "object") (_config$value$onRecor = (_config$value = config.value).onRecordingChange) === null || _config$value$onRecor === void 0 || _config$value$onRecor.call(_config$value, false);
|
|
170
|
+
options.onEnd({
|
|
171
|
+
source: "capture",
|
|
172
|
+
reason,
|
|
173
|
+
startedAt: startedAt.value,
|
|
174
|
+
endedAt,
|
|
175
|
+
duration: endedAt - startedAt.value,
|
|
176
|
+
chunks: chunks.value
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
return function stopCapture() {
|
|
180
|
+
return _ref2.apply(this, arguments);
|
|
181
|
+
};
|
|
182
|
+
}();
|
|
183
|
+
const startCapture = function() {
|
|
184
|
+
var _ref3 = _asyncToGenerator(function* () {
|
|
185
|
+
if (requesting.value || internalRecording.value || !available.value) return;
|
|
186
|
+
requesting.value = true;
|
|
187
|
+
captureError.value = void 0;
|
|
188
|
+
let phase = "permission";
|
|
189
|
+
try {
|
|
190
|
+
var _speechConfig$audioCo, _speechConfig$process, _socket$value3, _speechConfig$onRecor;
|
|
191
|
+
const speechConfig = typeof config.value === "object" ? config.value : void 0;
|
|
192
|
+
const bufferSize = resolveBufferSize(speechConfig === null || speechConfig === void 0 ? void 0 : speechConfig.bufferSize);
|
|
193
|
+
stream.value = yield navigator.mediaDevices.getUserMedia({
|
|
194
|
+
audio: (_speechConfig$audioCo = speechConfig === null || speechConfig === void 0 ? void 0 : speechConfig.audioConstraints) !== null && _speechConfig$audioCo !== void 0 ? _speechConfig$audioCo : true,
|
|
195
|
+
video: false
|
|
196
|
+
});
|
|
197
|
+
if (disposed) {
|
|
198
|
+
yield releaseResources();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (speechConfig === null || speechConfig === void 0 ? void 0 : speechConfig.url) {
|
|
202
|
+
phase = "transport";
|
|
203
|
+
yield connectTransport(speechConfig.url, speechConfig.protocols);
|
|
204
|
+
if (disposed) {
|
|
205
|
+
yield releaseResources();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
phase = "audioContext";
|
|
210
|
+
const nextAudioContext = resolveAudioContext();
|
|
211
|
+
audioContext.value = nextAudioContext;
|
|
212
|
+
phase = "audioWorklet";
|
|
213
|
+
yield nextAudioContext.audioWorklet.addModule(resolveWorkletUrl());
|
|
214
|
+
if (disposed) {
|
|
215
|
+
yield releaseResources();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const processorName = (_speechConfig$process = speechConfig === null || speechConfig === void 0 ? void 0 : speechConfig.processorName) !== null && _speechConfig$process !== void 0 ? _speechConfig$process : DEFAULT_PROCESSOR_NAME;
|
|
219
|
+
const nextWorkletNode = new AudioWorkletNode(nextAudioContext, processorName, {
|
|
220
|
+
numberOfInputs: 1,
|
|
221
|
+
numberOfOutputs: 0,
|
|
222
|
+
channelCount: 1,
|
|
223
|
+
processorOptions: _objectSpread2(_objectSpread2({}, speechConfig === null || speechConfig === void 0 ? void 0 : speechConfig.processorOptions), {}, { bufferSize })
|
|
224
|
+
});
|
|
225
|
+
workletNode.value = nextWorkletNode;
|
|
226
|
+
sourceNode.value = nextAudioContext.createMediaStreamSource(stream.value);
|
|
227
|
+
nextWorkletNode.port.onmessage = (event) => {
|
|
228
|
+
var _socket$value2;
|
|
229
|
+
if (!(event.data instanceof ArrayBuffer) && "type" in event.data) {
|
|
230
|
+
if (event.data.type === "flushed") resolveWorkletFlush === null || resolveWorkletFlush === void 0 || resolveWorkletFlush();
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (!internalRecording.value) return;
|
|
234
|
+
const buffer = event.data;
|
|
235
|
+
const dataEvent = {
|
|
236
|
+
buffer,
|
|
237
|
+
sampleRate: nextAudioContext.sampleRate,
|
|
238
|
+
sequence: sequence.value,
|
|
239
|
+
timestamp: performance.now()
|
|
240
|
+
};
|
|
241
|
+
sequence.value += 1;
|
|
242
|
+
chunks.value += 1;
|
|
243
|
+
options.onData(dataEvent);
|
|
244
|
+
if (((_socket$value2 = socket.value) === null || _socket$value2 === void 0 ? void 0 : _socket$value2.readyState) === WebSocket.OPEN) socket.value.send(buffer);
|
|
245
|
+
};
|
|
246
|
+
sourceNode.value.connect(nextWorkletNode);
|
|
247
|
+
startedAt.value = performance.now();
|
|
248
|
+
chunks.value = 0;
|
|
249
|
+
sequence.value = 0;
|
|
250
|
+
internalRecording.value = true;
|
|
251
|
+
if (((_socket$value3 = socket.value) === null || _socket$value3 === void 0 ? void 0 : _socket$value3.readyState) === WebSocket.OPEN && (speechConfig === null || speechConfig === void 0 ? void 0 : speechConfig.sendMetadata) !== false) socket.value.send(JSON.stringify({
|
|
252
|
+
type: "start",
|
|
253
|
+
format: "pcm-f32",
|
|
254
|
+
channels: 1,
|
|
255
|
+
sampleRate: nextAudioContext.sampleRate,
|
|
256
|
+
bufferSize
|
|
257
|
+
}));
|
|
258
|
+
speechConfig === null || speechConfig === void 0 || (_speechConfig$onRecor = speechConfig.onRecordingChange) === null || _speechConfig$onRecor === void 0 || _speechConfig$onRecor.call(speechConfig, true);
|
|
259
|
+
options.onStart({
|
|
260
|
+
source: "capture",
|
|
261
|
+
startedAt: startedAt.value,
|
|
262
|
+
stream: stream.value,
|
|
263
|
+
audioContext: nextAudioContext,
|
|
264
|
+
sampleRate: nextAudioContext.sampleRate
|
|
265
|
+
});
|
|
266
|
+
} catch (error) {
|
|
267
|
+
const errorEvent = {
|
|
268
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
269
|
+
phase
|
|
270
|
+
};
|
|
271
|
+
captureError.value = errorEvent;
|
|
272
|
+
options.onError(errorEvent);
|
|
273
|
+
yield releaseResources();
|
|
274
|
+
} finally {
|
|
275
|
+
requesting.value = false;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
return function startCapture() {
|
|
279
|
+
return _ref3.apply(this, arguments);
|
|
280
|
+
};
|
|
281
|
+
}();
|
|
282
|
+
const trigger = function() {
|
|
283
|
+
var _ref4 = _asyncToGenerator(function* (breakRecording = false) {
|
|
284
|
+
if (breakRecording && !recording.value) return;
|
|
285
|
+
if (controlled.value && typeof config.value === "object") {
|
|
286
|
+
var _config$value$onRecor2, _config$value2;
|
|
287
|
+
const nextRecording = !recording.value;
|
|
288
|
+
(_config$value$onRecor2 = (_config$value2 = config.value).onRecordingChange) === null || _config$value$onRecor2 === void 0 || _config$value$onRecor2.call(_config$value2, nextRecording);
|
|
289
|
+
const now = performance.now();
|
|
290
|
+
if (nextRecording) {
|
|
291
|
+
startedAt.value = now;
|
|
292
|
+
options.onStart({
|
|
293
|
+
source: "controlled",
|
|
294
|
+
startedAt: now
|
|
295
|
+
});
|
|
296
|
+
} else options.onEnd({
|
|
297
|
+
source: "controlled",
|
|
298
|
+
reason: "controlled",
|
|
299
|
+
startedAt: startedAt.value,
|
|
300
|
+
endedAt: now,
|
|
301
|
+
duration: now - startedAt.value,
|
|
302
|
+
chunks: 0
|
|
303
|
+
});
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (internalRecording.value) yield stopCapture();
|
|
307
|
+
else yield startCapture();
|
|
308
|
+
});
|
|
309
|
+
return function trigger() {
|
|
310
|
+
return _ref4.apply(this, arguments);
|
|
311
|
+
};
|
|
312
|
+
}();
|
|
313
|
+
onMounted(() => {
|
|
314
|
+
var _navigator$mediaDevic;
|
|
315
|
+
supported.value = Boolean(typeof ((_navigator$mediaDevic = navigator.mediaDevices) === null || _navigator$mediaDevic === void 0 ? void 0 : _navigator$mediaDevic.getUserMedia) === "function" && typeof AudioContext !== "undefined" && typeof AudioWorkletNode !== "undefined");
|
|
316
|
+
});
|
|
317
|
+
watch(() => Boolean(config.value), (enabled) => {
|
|
318
|
+
if (!enabled) stopCapture();
|
|
319
|
+
});
|
|
320
|
+
watch(controlled, (nextControlled) => {
|
|
321
|
+
if (nextControlled) stopCapture();
|
|
322
|
+
});
|
|
323
|
+
onBeforeUnmount(_asyncToGenerator(function* () {
|
|
324
|
+
disposed = true;
|
|
325
|
+
if (internalRecording.value) yield stopCapture("unmount");
|
|
326
|
+
else yield releaseResources();
|
|
327
|
+
if (generatedWorkletUrl) URL.revokeObjectURL(generatedWorkletUrl);
|
|
328
|
+
}));
|
|
329
|
+
return {
|
|
330
|
+
available,
|
|
331
|
+
recording,
|
|
332
|
+
requesting,
|
|
333
|
+
statusText,
|
|
334
|
+
trigger
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
338
|
+
export { useSpeech };
|
package/es/slider/index.d.ts
CHANGED
|
@@ -63,12 +63,12 @@ declare const Slider: {
|
|
|
63
63
|
change: (_value: number | [number, number]) => any;
|
|
64
64
|
"update:modelValue": (_value: number | [number, number]) => any;
|
|
65
65
|
}, import("vue").PublicProps, {
|
|
66
|
+
range: boolean;
|
|
66
67
|
disabled: boolean;
|
|
67
68
|
direction: "horizontal" | "vertical";
|
|
68
69
|
defaultValue: number | [number, number];
|
|
69
70
|
modelValue: number | [number, number];
|
|
70
71
|
max: number;
|
|
71
|
-
range: boolean;
|
|
72
72
|
step: number;
|
|
73
73
|
min: number;
|
|
74
74
|
showTooltip: boolean;
|
|
@@ -136,12 +136,12 @@ declare const Slider: {
|
|
|
136
136
|
onChange?: ((_value: number | [number, number]) => any) | undefined;
|
|
137
137
|
"onUpdate:modelValue"?: ((_value: number | [number, number]) => any) | undefined;
|
|
138
138
|
}>, {}, {}, {}, {}, {
|
|
139
|
+
range: boolean;
|
|
139
140
|
disabled: boolean;
|
|
140
141
|
direction: "horizontal" | "vertical";
|
|
141
142
|
defaultValue: number | [number, number];
|
|
142
143
|
modelValue: number | [number, number];
|
|
143
144
|
max: number;
|
|
144
|
-
range: boolean;
|
|
145
145
|
step: number;
|
|
146
146
|
min: number;
|
|
147
147
|
showTooltip: boolean;
|
|
@@ -209,12 +209,12 @@ declare const Slider: {
|
|
|
209
209
|
change: (_value: number | [number, number]) => any;
|
|
210
210
|
"update:modelValue": (_value: number | [number, number]) => any;
|
|
211
211
|
}, string, {
|
|
212
|
+
range: boolean;
|
|
212
213
|
disabled: boolean;
|
|
213
214
|
direction: "horizontal" | "vertical";
|
|
214
215
|
defaultValue: number | [number, number];
|
|
215
216
|
modelValue: number | [number, number];
|
|
216
217
|
max: number;
|
|
217
|
-
range: boolean;
|
|
218
218
|
step: number;
|
|
219
219
|
min: number;
|
|
220
220
|
showTooltip: boolean;
|
|
@@ -46,8 +46,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
46
46
|
onStartChange?: ((_value?: number | undefined) => any) | undefined;
|
|
47
47
|
onEndChange?: ((_value?: number | undefined) => any) | undefined;
|
|
48
48
|
}>, {
|
|
49
|
-
disabled: boolean;
|
|
50
49
|
range: boolean;
|
|
50
|
+
disabled: boolean;
|
|
51
51
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
52
52
|
declare const _default: typeof __VLS_export;
|
|
53
53
|
export default _default;
|
|
@@ -109,12 +109,12 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
109
109
|
onChange?: ((_value: number | [number, number]) => any) | undefined;
|
|
110
110
|
"onUpdate:modelValue"?: ((_value: number | [number, number]) => any) | undefined;
|
|
111
111
|
}>, {
|
|
112
|
+
range: boolean;
|
|
112
113
|
disabled: boolean;
|
|
113
114
|
direction: "horizontal" | "vertical";
|
|
114
115
|
defaultValue: number | [number, number];
|
|
115
116
|
modelValue: number | [number, number];
|
|
116
117
|
max: number;
|
|
117
|
-
range: boolean;
|
|
118
118
|
step: number;
|
|
119
119
|
min: number;
|
|
120
120
|
showTooltip: boolean;
|