@corti/dictation-web
Version:
Web component for Corti Dictation
131 lines • 3.47 kB
JavaScript
export function languagesChangedEvent(languages, selectedLanguage) {
return new CustomEvent("languages-changed", {
bubbles: true,
composed: true,
detail: { languages, selectedLanguage },
});
}
/**
* @deprecated Use languagesChangedEvent instead. This event is kept for backward compatibility.
*/
export function languageChangedEvent(language) {
return new CustomEvent("language-changed", {
bubbles: true,
composed: true,
detail: { language },
});
}
export function recordingDevicesChangedEvent(devices, selectedDevice) {
return new CustomEvent("recording-devices-changed", {
bubbles: true,
composed: true,
detail: { devices, selectedDevice },
});
}
export function recordingStateChangedEvent(state, options = {}) {
return new CustomEvent("recording-state-changed", {
bubbles: true,
composed: true,
detail: {
connection: options.connection,
processing: options.processing,
state,
},
});
}
export function transcriptEvent(detail) {
return new CustomEvent("transcript", {
bubbles: true,
composed: true,
detail,
});
}
export function commandEvent(detail) {
return new CustomEvent("command", {
bubbles: true,
composed: true,
detail,
});
}
export function usageEvent(detail) {
return new CustomEvent("usage", {
bubbles: true,
composed: true,
detail,
});
}
export function deltaUsageEvent(detail) {
return new CustomEvent("delta-usage", {
bubbles: true,
composed: true,
detail,
});
}
function errorToMessage(error) {
if (error instanceof Error) {
return error.message;
}
if (typeof error === "object" && error !== null) {
try {
return JSON.stringify(error);
}
catch {
return String(error);
}
}
return String(error);
}
export function errorEvent(error) {
const message = errorToMessage(error);
return new CustomEvent("error", {
bubbles: false,
composed: true,
detail: { message },
});
}
/**
* @deprecated Use recording-state-changed event with detail.connection field instead.
*/
export function streamClosedEvent(detail) {
return new CustomEvent("stream-closed", {
bubbles: true,
composed: true,
detail,
});
}
export function readyEvent() {
return new CustomEvent("ready", {
bubbles: true,
composed: true,
});
}
export function audioLevelChangedEvent(audioLevel) {
return new CustomEvent("audio-level-changed", {
bubbles: true,
composed: true,
detail: { audioLevel },
});
}
export function networkActivityEvent(direction, data) {
return new CustomEvent("network-activity", {
bubbles: true,
composed: true,
detail: { data, direction },
});
}
export function keybindingChangedEvent(key, code, keybinding, type) {
return new CustomEvent("keybinding-changed", {
bubbles: true,
composed: true,
detail: { code, key, keybinding, type },
});
}
export function keybindingActivatedEvent(keyboardEvent) {
return new CustomEvent("keybinding-activated", {
bubbles: true,
cancelable: true,
composed: true,
detail: { keyboardEvent },
});
}
//# sourceMappingURL=events.js.map