react-text-to-speech
Advanced tools
Comparing version 0.14.1 to 0.14.2
import React from "react"; | ||
import { dequeue, clearQueueHook } from "./queue.js"; | ||
import { dequeue } from "./queue.js"; | ||
import { SpeechStatus, useSpeechProps, SpeechUtterancesQueue } from "./types.js"; | ||
@@ -7,3 +7,3 @@ export declare function useQueue(): { | ||
dequeue: typeof dequeue; | ||
clearQueue: typeof clearQueueHook; | ||
clearQueue: () => void; | ||
}; | ||
@@ -10,0 +10,0 @@ export declare function useSpeech({ text, pitch, rate, volume, lang, voiceURI, highlightText, highlightProps, preserveUtteranceQueue, onError, onStart, onResume, onPause, onStop, onBoundary, onQueueChange, }: useSpeechProps): { |
import { QueueChangeEventHandler, SpeechQueueItem } from "./types.js"; | ||
export declare function clearQueue(start?: number, emitEvent?: boolean): void; | ||
export declare function clearQueue(cancelSpeech?: boolean, start?: number, emitEvent?: boolean): void; | ||
export declare function addToQueue(item: SpeechQueueItem, callback?: QueueChangeEventHandler): void; | ||
export declare function clearQueueHook(): void; | ||
export declare function clearQueueUnload(): void; | ||
export declare const clearQueueHook: () => void; | ||
export declare const clearQueueUnload: () => void; | ||
export declare function dequeue(index?: number): void; | ||
@@ -7,0 +7,0 @@ export declare function emit(callback?: QueueChangeEventHandler): void; |
import { cancel } from "./utils.js"; | ||
const queue = []; | ||
const queueListeners = []; | ||
export function clearQueue(start = 0, emitEvent = false) { | ||
export function clearQueue(cancelSpeech = false, start = 0, emitEvent = false) { | ||
if (cancelSpeech) | ||
cancel(); | ||
queue.slice(start).forEach(({ setSpeechStatus }) => setSpeechStatus("stopped")); | ||
@@ -14,10 +16,4 @@ queue.length = 0; | ||
} | ||
export function clearQueueHook() { | ||
cancel(); | ||
clearQueue(1, true); | ||
} | ||
export function clearQueueUnload() { | ||
cancel(); | ||
clearQueue(1); | ||
} | ||
export const clearQueueHook = () => clearQueue(true, 1, true); | ||
export const clearQueueUnload = () => clearQueue(true, 1); | ||
export function dequeue(index = 0) { | ||
@@ -24,0 +20,0 @@ if (index === 0) |
@@ -7,4 +7,4 @@ import { ReactNode } from "react"; | ||
export declare function findCharIndex(words: StringArray, index: number): string; | ||
export declare function getIndex(parentIndex: Index, index: Index): string; | ||
export declare const getIndex: (parentIndex: Index, index: Index) => string; | ||
export declare function isParent(parentIndex: string, index?: string): boolean; | ||
export declare const sanitize: (text: string) => string; |
@@ -39,5 +39,3 @@ import { isValidElement } from "react"; | ||
} | ||
export function getIndex(parentIndex, index) { | ||
return `${parentIndex === "" ? "" : parentIndex + "-"}${index}`; | ||
} | ||
export const getIndex = (parentIndex, index) => `${parentIndex === "" ? "" : parentIndex + "-"}${index}`; | ||
export function isParent(parentIndex, index) { | ||
@@ -56,2 +54,2 @@ if (!(index === null || index === void 0 ? void 0 : index.startsWith(parentIndex))) | ||
} | ||
export const sanitize = (text) => text.replace(/[;<>]/g, (match) => (match === ">" ? ")" : "(")); | ||
export const sanitize = (text) => text.replace(/<([^>]+)>|;/g, (_, group) => (group ? `(${group})` : "(")); |
{ | ||
"name": "react-text-to-speech", | ||
"version": "0.14.1", | ||
"version": "0.14.2", | ||
"description": "An easy to use react component for the Web Speech API.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
37933
11
412