UNPKG

react-say-fork

Version:

# Goal and TODOs * Add Typescript support * Make compononents style-customizable

48 lines (47 loc) 2.14 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Say_1 = __importDefault(require("./Say")); const SayButton_1 = __importDefault(require("./SayButton")); const warnings = { ponyfill: true, saySpeak: true, }; function migrateDeprecatedProps(_a, componentType) { var { ponyfill, speak, speechSynthesis, speechSynthesisUtterance, text } = _a, otherProps = __rest(_a, ["ponyfill", "speak", "speechSynthesis", "speechSynthesisUtterance", "text"]); if (!ponyfill && (speechSynthesis || speechSynthesisUtterance)) { if (warnings.ponyfill) { console.warn('react-say: "speechSynthesis" and "speechSynthesisUtterance" props has been renamed to "ponyfill". Please update your code. The deprecated props will be removed in version >= 3.0.0.'); warnings.ponyfill = false; } ponyfill = { speechSynthesis, SpeechSynthesisUtterance: speechSynthesisUtterance, }; } if (componentType === Say_1.default || componentType === SayButton_1.default) { if (speak && !text) { if (warnings.saySpeak) { console.warn('react-say: "speak" prop has been renamed to "text". Please update your code. The deprecated props will be removed in version >= 3.0.0.'); warnings.saySpeak = false; } text = speak; } } return Object.assign({ ponyfill, text }, otherProps); } exports.default = migrateDeprecatedProps;