New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-text-to-speech

Package Overview
Dependencies
Maintainers
0
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-text-to-speech - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

1

dist/constants.d.ts

@@ -13,4 +13,3 @@ export declare const lineDelimiter = "\n";

export declare const sentenceDelimiters: string[];
export declare const spaceDelimiters: string[];
export declare const specialSymbol = "\u00A0";
export declare const utterancePropertiesAndEvents: (keyof SpeechSynthesisUtterance)[];

@@ -11,3 +11,2 @@ export const lineDelimiter = "\n";

export const sentenceDelimiters = [lineDelimiter, ...punctuationDelimiters];
export const spaceDelimiters = [lineDelimiter, spaceDelimiter];
export const specialSymbol = "\u00A0";

@@ -14,0 +13,0 @@ const utteranceEvents = ["onstart", "onend", "onerror", "onpause", "onresume", "onmark", "onboundary"];

2

dist/hooks.js

@@ -98,3 +98,3 @@ import React, { cloneElement, isValidElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";

const index = findCharIndex(words, offset + charIndex - isSpecialSymbol);
if (shouldHighlightNextPart(highlightMode, name, utterance, charIndex, isSpecialSymbol) || parent(index) !== parent((_a = speakingWordRef.current) === null || _a === void 0 ? void 0 : _a.index))
if (shouldHighlightNextPart(highlightMode, name, utterance, charIndex) || parent(index) !== parent((_a = speakingWordRef.current) === null || _a === void 0 ? void 0 : _a.index))
setSpeakingWord({ index, length: isSpecialSymbol || charLength });

@@ -101,0 +101,0 @@ if (isSpecialSymbol)

@@ -14,3 +14,3 @@ import { ReactNode } from "react";

export declare const sanitize: (text: string) => string;
export declare function shouldHighlightNextPart(highlightMode: HighlightMode, name: SpeechSynthesisEventName, utterance: SpeechSynthesisUtterance, charIndex: number, isSpecialSymbol: number): boolean;
export declare function shouldHighlightNextPart(highlightMode: HighlightMode, name: SpeechSynthesisEventName, utterance: SpeechSynthesisUtterance, charIndex: number): boolean;
export declare function splitNode(highlightMode: HighlightMode, node: string, speakingWord: SpeakingWord): [string, string, string];
import { isValidElement } from "react";
import { chunkDelimiters, desktopChunkSize, lineDelimiter, minChunkSize, mobileChunkSize, sanitizeRegex, sentenceDelimiters, spaceDelimiter, spaceDelimiters, specialSymbol, symbolMapping, utterancePropertiesAndEvents, } from "./constants.js";
import { chunkDelimiters, desktopChunkSize, lineDelimiter, minChunkSize, mobileChunkSize, sanitizeRegex, sentenceDelimiters, spaceDelimiter, specialSymbol, symbolMapping, utterancePropertiesAndEvents, } from "./constants.js";
import { setState } from "./state.js";

@@ -25,3 +25,3 @@ export function ArrayToText(node) {

let endIndex = Math.min(startIndex + size, length);
if (endIndex < length && !spaceDelimiters.includes(text[endIndex]))
if (endIndex < length && text[endIndex] !== lineDelimiter)
for (const delimiter of chunkDelimiters) {

@@ -96,9 +96,12 @@ let delimiterIndex = text.lastIndexOf(delimiter, endIndex) + delimiter.length - 1;

export const sanitize = (text) => text.replace(sanitizeRegex, (match, group) => (group ? group + ")" : ` ${symbolMapping[match]}${specialSymbol}`));
export function shouldHighlightNextPart(highlightMode, name, utterance, charIndex, isSpecialSymbol) {
export function shouldHighlightNextPart(highlightMode, name, utterance, charIndex) {
if (name === "word" && (highlightMode === "word" || !charIndex))
return true;
const text = utterance.text.slice(0, charIndex).replace(/[ \t]+$/, spaceDelimiter);
if (highlightMode === "sentence" && (text.at(-isSpecialSymbol - 1) === lineDelimiter || sentenceDelimiters.includes(text.at(-2))))
const text = utterance.text
.slice(0, charIndex)
.replace(/[ \t]+$/, spaceDelimiter)
.slice(-2);
if (highlightMode === "sentence" && (text[1] === lineDelimiter || (sentenceDelimiters.includes(text[0]) && text[1] === spaceDelimiter)))
return true;
if (highlightMode === "line" && text.at(-isSpecialSymbol - 1) === lineDelimiter)
if (highlightMode === "line" && (text[1] === lineDelimiter || (text[0] === lineDelimiter && text[1] === spaceDelimiter)))
return true;

@@ -105,0 +108,0 @@ if (highlightMode === "paragraph" && name === "sentence")

{
"name": "react-text-to-speech",
"version": "1.1.0",
"version": "1.1.1",
"description": "An easy-to-use React.js component that leverages the Web Speech API to convert text to speech.",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc