@bitrix24/b24ui-nuxt 2.1.10 → 2.1.11
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/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/useSpeechRecognition.d.ts +122 -0
- package/dist/runtime/composables/useSpeechRecognition.js +166 -0
- package/dist/shared/{b24ui-nuxt.BCphUjPy.mjs → b24ui-nuxt.Dh5A-7HA.mjs} +3 -1
- package/dist/unplugin.mjs +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defu } from 'defu';
|
|
2
2
|
import { defineNuxtModule, createResolver, addPlugin, hasNuxtModule, addComponentsDir, addImportsDir, installModule } from '@nuxt/kit';
|
|
3
|
-
import { d as defaultOptions, v as version, n as name, a as getDefaultConfig, b as addTemplates } from './shared/b24ui-nuxt.
|
|
3
|
+
import { d as defaultOptions, v as version, n as name, a as getDefaultConfig, b as addTemplates } from './shared/b24ui-nuxt.Dh5A-7HA.mjs';
|
|
4
4
|
import 'node:url';
|
|
5
5
|
import 'scule';
|
|
6
6
|
import 'knitwork';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { Ref, DeepReadonly } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Speech recognition Web API types
|
|
4
|
+
* @see /bitrix/js/im/v2/component/textarea/src/components/audio-input/classes/audio-manager.js
|
|
5
|
+
*/
|
|
6
|
+
export type SpeechRecognitionErrorCode = 'aborted' | 'audio-capture' | 'bad-grammar' | 'language-not-supported' | 'network' | 'no-speech' | 'not-allowed' | 'service-not-allowed';
|
|
7
|
+
interface SpeechGrammar {
|
|
8
|
+
src: string;
|
|
9
|
+
weight: number;
|
|
10
|
+
}
|
|
11
|
+
interface SpeechGrammarList {
|
|
12
|
+
readonly length: number;
|
|
13
|
+
addFromString: (string: string, weight?: number) => void;
|
|
14
|
+
addFromURI: (src: string, weight?: number) => void;
|
|
15
|
+
item: (index: number) => SpeechGrammar;
|
|
16
|
+
[index: number]: SpeechGrammar;
|
|
17
|
+
}
|
|
18
|
+
export interface SpeechRecognitionErrorEvent extends Event {
|
|
19
|
+
readonly error: SpeechRecognitionErrorCode;
|
|
20
|
+
readonly message: string;
|
|
21
|
+
}
|
|
22
|
+
interface SpeechRecognitionEvent extends Event {
|
|
23
|
+
readonly resultIndex: number;
|
|
24
|
+
readonly results: SpeechRecognitionResultList;
|
|
25
|
+
}
|
|
26
|
+
interface SpeechRecognitionEventMap {
|
|
27
|
+
audioend: Event;
|
|
28
|
+
audiostart: Event;
|
|
29
|
+
end: Event;
|
|
30
|
+
error: SpeechRecognitionErrorEvent;
|
|
31
|
+
nomatch: SpeechRecognitionEvent;
|
|
32
|
+
result: SpeechRecognitionEvent;
|
|
33
|
+
soundend: Event;
|
|
34
|
+
soundstart: Event;
|
|
35
|
+
speechend: Event;
|
|
36
|
+
speechstart: Event;
|
|
37
|
+
start: Event;
|
|
38
|
+
}
|
|
39
|
+
export interface SpeechRecognition extends EventTarget {
|
|
40
|
+
continuous: boolean;
|
|
41
|
+
grammars: SpeechGrammarList;
|
|
42
|
+
interimResults: boolean;
|
|
43
|
+
lang: string;
|
|
44
|
+
maxAlternatives: number;
|
|
45
|
+
onaudioend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
46
|
+
onaudiostart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
47
|
+
onend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
48
|
+
onerror: ((this: SpeechRecognition, ev: SpeechRecognitionErrorEvent) => any) | null;
|
|
49
|
+
onnomatch: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
|
|
50
|
+
onresult: ((this: SpeechRecognition, ev: SpeechRecognitionEvent) => any) | null;
|
|
51
|
+
onsoundend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
52
|
+
onsoundstart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
53
|
+
onspeechend: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
54
|
+
onspeechstart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
55
|
+
onstart: ((this: SpeechRecognition, ev: Event) => any) | null;
|
|
56
|
+
abort: () => void;
|
|
57
|
+
start: () => void;
|
|
58
|
+
stop: () => void;
|
|
59
|
+
addEventListener: (<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | AddEventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void);
|
|
60
|
+
removeEventListener: (<K extends keyof SpeechRecognitionEventMap>(type: K, listener: (this: SpeechRecognition, ev: SpeechRecognitionEventMap[K]) => any, options?: boolean | EventListenerOptions) => void) & ((type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions) => void);
|
|
61
|
+
}
|
|
62
|
+
export interface SpeechRecognitionOptions {
|
|
63
|
+
/** Recognition language (default: 'en-US') */
|
|
64
|
+
lang?: string;
|
|
65
|
+
/** Continuous recognition (default: true) */
|
|
66
|
+
continuous?: boolean;
|
|
67
|
+
/** Interim results (default: true) */
|
|
68
|
+
interimResults?: boolean;
|
|
69
|
+
/** Максимальное количество альтернатив (по умолчанию: 1) */
|
|
70
|
+
maxAlternatives?: number;
|
|
71
|
+
}
|
|
72
|
+
export interface SpeechRecognitionResult {
|
|
73
|
+
/** Recognized text */
|
|
74
|
+
text: string;
|
|
75
|
+
}
|
|
76
|
+
export interface SpeechRecognitionState {
|
|
77
|
+
/** Whether speech recognition is available in the browser */
|
|
78
|
+
isAvailable: boolean;
|
|
79
|
+
/** Whether recognition is currently active */
|
|
80
|
+
isListening: boolean;
|
|
81
|
+
/** All recognized text (accumulated if continuous mode) */
|
|
82
|
+
lastRecognizedText: string;
|
|
83
|
+
}
|
|
84
|
+
export interface SpeechRecognitionControls {
|
|
85
|
+
/** Start recognition */
|
|
86
|
+
start: () => Promise<boolean>;
|
|
87
|
+
/** Stop recognition */
|
|
88
|
+
stop: () => Promise<boolean>;
|
|
89
|
+
/** Toggle recognition state */
|
|
90
|
+
toggle: () => Promise<boolean>;
|
|
91
|
+
/** Set recognition language */
|
|
92
|
+
setLanguage: (lang: string) => boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface SpeechRecognitionEvents {
|
|
95
|
+
/** Called when recognition starts */
|
|
96
|
+
onStart?: () => void;
|
|
97
|
+
/** Called when recognition ends */
|
|
98
|
+
onEnd?: () => void;
|
|
99
|
+
/** Called on error */
|
|
100
|
+
onError?: (error: string) => void;
|
|
101
|
+
/** Called when a result is received */
|
|
102
|
+
onResult?: (result: SpeechRecognitionResult) => void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Universal composable for speech recognition
|
|
106
|
+
* Can be used with any input components (Input, Textarea, etc.)
|
|
107
|
+
*/
|
|
108
|
+
export declare function useSpeechRecognition(options?: SpeechRecognitionOptions, events?: SpeechRecognitionEvents): {
|
|
109
|
+
state: DeepReadonly<Ref<SpeechRecognitionState>>;
|
|
110
|
+
isAvailable: import("vue").ComputedRef<boolean>;
|
|
111
|
+
isListening: import("vue").ComputedRef<boolean>;
|
|
112
|
+
start: () => Promise<boolean>;
|
|
113
|
+
stop: () => Promise<boolean>;
|
|
114
|
+
toggle: () => Promise<boolean>;
|
|
115
|
+
setLanguage: (lang: string) => boolean;
|
|
116
|
+
recognizer: SpeechRecognition | undefined;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Return type of useSpeechRecognition
|
|
120
|
+
*/
|
|
121
|
+
export type UseSpeechRecognitionReturn = ReturnType<typeof useSpeechRecognition>;
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { ref, computed, onMounted, onBeforeUnmount, readonly } from "vue";
|
|
2
|
+
export function useSpeechRecognition(options = {}, events = {}) {
|
|
3
|
+
const {
|
|
4
|
+
lang = "en-US",
|
|
5
|
+
continuous = true,
|
|
6
|
+
interimResults = true,
|
|
7
|
+
maxAlternatives = 1
|
|
8
|
+
} = options;
|
|
9
|
+
const {
|
|
10
|
+
onStart,
|
|
11
|
+
onEnd,
|
|
12
|
+
onError,
|
|
13
|
+
onResult
|
|
14
|
+
} = events;
|
|
15
|
+
const state = ref({
|
|
16
|
+
isAvailable: false,
|
|
17
|
+
isListening: false,
|
|
18
|
+
lastRecognizedText: ""
|
|
19
|
+
});
|
|
20
|
+
let recognizer;
|
|
21
|
+
const isAvailable = computed(() => state.value.isAvailable);
|
|
22
|
+
const isListening = computed(() => state.value.isListening);
|
|
23
|
+
const init = () => {
|
|
24
|
+
if (typeof window === "undefined") {
|
|
25
|
+
onError?.("Speech recognition is not available in this environment");
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const SpeechRecognition = window && (window.SpeechRecognition || window.webkitSpeechRecognition);
|
|
29
|
+
if (!SpeechRecognition) {
|
|
30
|
+
state.value.isAvailable = false;
|
|
31
|
+
onError?.("Speech recognition is not supported in this browser");
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
recognizer = new SpeechRecognition();
|
|
36
|
+
recognizer.lang = lang;
|
|
37
|
+
recognizer.continuous = continuous;
|
|
38
|
+
recognizer.interimResults = interimResults;
|
|
39
|
+
recognizer.maxAlternatives = maxAlternatives;
|
|
40
|
+
setupEventHandlers();
|
|
41
|
+
state.value.isAvailable = true;
|
|
42
|
+
return true;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
onError?.(error instanceof Error ? error.message : "Failed to initialize speech recognition");
|
|
45
|
+
state.value.isAvailable = false;
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const setupEventHandlers = () => {
|
|
50
|
+
if (!recognizer) return;
|
|
51
|
+
recognizer.onstart = () => {
|
|
52
|
+
state.value.isListening = true;
|
|
53
|
+
onStart?.();
|
|
54
|
+
};
|
|
55
|
+
recognizer.onerror = (event) => {
|
|
56
|
+
state.value.isListening = false;
|
|
57
|
+
onError?.(event.error);
|
|
58
|
+
};
|
|
59
|
+
recognizer.onend = () => {
|
|
60
|
+
state.value.isListening = false;
|
|
61
|
+
onEnd?.();
|
|
62
|
+
};
|
|
63
|
+
recognizer.onresult = (event) => {
|
|
64
|
+
const recognizedText = _getRecognizedText(event);
|
|
65
|
+
const nextText = _getNewText(recognizedText);
|
|
66
|
+
if (nextText !== "") {
|
|
67
|
+
onResult?.({ text: nextText });
|
|
68
|
+
}
|
|
69
|
+
state.value.lastRecognizedText = recognizedText;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const _getRecognizedText = (event) => {
|
|
73
|
+
let recognizedChunk = "";
|
|
74
|
+
Object.values(event.results).forEach((result) => {
|
|
75
|
+
if (result.isFinal) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const [alternative] = result;
|
|
79
|
+
const { transcript } = alternative;
|
|
80
|
+
recognizedChunk += transcript;
|
|
81
|
+
});
|
|
82
|
+
return recognizedChunk;
|
|
83
|
+
};
|
|
84
|
+
const _getNewText = (fullText) => {
|
|
85
|
+
let additionalText = "";
|
|
86
|
+
const lastChunkLength = state.value.lastRecognizedText.length;
|
|
87
|
+
if (fullText.length > lastChunkLength) {
|
|
88
|
+
additionalText = fullText.slice(lastChunkLength);
|
|
89
|
+
}
|
|
90
|
+
return additionalText;
|
|
91
|
+
};
|
|
92
|
+
const start = async () => {
|
|
93
|
+
if (!state.value.isAvailable) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
if (state.value.isListening) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (!recognizer) {
|
|
100
|
+
if (!init()) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
recognizer.start();
|
|
106
|
+
return true;
|
|
107
|
+
} catch (error) {
|
|
108
|
+
onError?.(error instanceof Error ? error.message : "Failed to start speech recognition");
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const stop = async () => {
|
|
113
|
+
if (!state.value.isListening || !recognizer) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
recognizer.stop();
|
|
118
|
+
return true;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
onError?.(error instanceof Error ? error.message : "Failed to stop speech recognition");
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const toggle = async () => {
|
|
125
|
+
if (state.value.isListening) {
|
|
126
|
+
return stop();
|
|
127
|
+
} else {
|
|
128
|
+
return start();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const setLanguage = (lang2) => {
|
|
132
|
+
if (!recognizer) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
recognizer.lang = lang2;
|
|
137
|
+
return true;
|
|
138
|
+
} catch (error) {
|
|
139
|
+
onError?.(error instanceof Error ? error.message : "Failed to set language");
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
onMounted(() => {
|
|
144
|
+
init();
|
|
145
|
+
});
|
|
146
|
+
onBeforeUnmount(() => {
|
|
147
|
+
if (state.value.isListening) {
|
|
148
|
+
stop();
|
|
149
|
+
}
|
|
150
|
+
recognizer = void 0;
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
// State (readonly)
|
|
154
|
+
state: readonly(state),
|
|
155
|
+
// Computed properties
|
|
156
|
+
isAvailable,
|
|
157
|
+
isListening,
|
|
158
|
+
// Controls
|
|
159
|
+
start,
|
|
160
|
+
stop,
|
|
161
|
+
toggle,
|
|
162
|
+
setLanguage,
|
|
163
|
+
// Recognizer instance (for advanced usage)
|
|
164
|
+
recognizer
|
|
165
|
+
};
|
|
166
|
+
}
|
|
@@ -8,7 +8,7 @@ import { globSync } from 'tinyglobby';
|
|
|
8
8
|
import { defuFn } from 'defu';
|
|
9
9
|
|
|
10
10
|
const name = "@bitrix24/b24ui-nuxt";
|
|
11
|
-
const version = "2.1.
|
|
11
|
+
const version = "2.1.11";
|
|
12
12
|
|
|
13
13
|
function getDefaultConfig(theme) {
|
|
14
14
|
return {
|
|
@@ -3836,6 +3836,7 @@ const inputDate = () => {
|
|
|
3836
3836
|
separatorIcon: "shrink-0 size-4 text-(--ui-color-base-6)"
|
|
3837
3837
|
},
|
|
3838
3838
|
variants: {
|
|
3839
|
+
...fieldGroupVariant,
|
|
3839
3840
|
size: {
|
|
3840
3841
|
xss: {
|
|
3841
3842
|
base: (prev) => [prev, "gap-0.20", "px-1"].join(" "),
|
|
@@ -4890,6 +4891,7 @@ const inputTime = () => {
|
|
|
4890
4891
|
].join(" ")
|
|
4891
4892
|
},
|
|
4892
4893
|
variants: {
|
|
4894
|
+
...fieldGroupVariant,
|
|
4893
4895
|
size: {
|
|
4894
4896
|
xss: {
|
|
4895
4897
|
base: (prev) => [prev, "gap-0.20", "px-1"].join(" "),
|
package/dist/unplugin.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { join, normalize } from 'pathe';
|
|
|
3
3
|
import { createUnplugin } from 'unplugin';
|
|
4
4
|
import { defu } from 'defu';
|
|
5
5
|
import tailwind from '@tailwindcss/vite';
|
|
6
|
-
import { g as getTemplates, d as defaultOptions, a as getDefaultConfig } from './shared/b24ui-nuxt.
|
|
6
|
+
import { g as getTemplates, d as defaultOptions, a as getDefaultConfig } from './shared/b24ui-nuxt.Dh5A-7HA.mjs';
|
|
7
7
|
import fs from 'node:fs';
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import MagicString from 'magic-string';
|
package/dist/vite.mjs
CHANGED
package/package.json
CHANGED